The minted package provides automatic syntax highlighting for source code listings. It uses the excellent pygments highlighter, which provides very high quality highlighting for a wide range of languages.
This example also shows how you can use minted to typeset LaTeX math embedded in your source code.
This is an example illustating how to typeset code in LaTeX, especially in beamer presentations. It uses the metropolis theme.
It is a presentation with one slide per "technique" which include some explanatory comments.
Examples shown are minted, lstlisting, verbatim, tcolorbox and knitR. The main document has the ending ".Rtex" which is required if you want it to be able to run knitR. Otherwise, you can just use normal ".tex".
It is accompanied by a blog post with more information here.
In this blog post, some complications which can arise when using code listings in beamer are discussed (package clashes, etc.), so this might be informative if you want to learn more.
Ejemplo de uso del archivo arduino_code.tex que define el comando ArduinoSketch y el ambiente ArduinoSketchBox para incluir código arduino en documento LaTeX utilizando el resaltado de sintaxis propio de Arduino IDE