-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathlatexExample.tex
More file actions
58 lines (47 loc) · 1.71 KB
/
latexExample.tex
File metadata and controls
58 lines (47 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
\documentclass[12pt]{article} % increase font size
\usepackage{listings} % for creating language style
\input{arduinoLanguage.tex} % adds the arduino language listing
%% Define an Arduino style fore use later %%
\lstdefinestyle{myArduino}{
language=Arduino,
%% Add other words needing highlighting below %%
morekeywords=[1]{}, % [1] -> dark green
morekeywords=[2]{FILE_WRITE}, % [2] -> light blue
morekeywords=[3]{SD, File}, % [3] -> bold orange
morekeywords=[4]{open, exists}, % [4] -> orange
%% The lines below add a nifty box around the code %%
frame=shadowbox,
rulesepcolor=\color{arduinoBlue},
}
\begin{document}
\section{SD Card Example}
Below is a snippet of arduino code. It was added via the input of the external
file arduinoLanguage.tex. A custom style was then created at the top of this
file so that the non-built-in functions and classes like SD and open() would highlight
properly. The style also adds the pretty box around the code. To see how this was
accomplished, check out latexExample.tex. \\
\begin{lstlisting}[style=myArduino]
#include <SD.h>
File logfile;
byte logPin = 10;
void setup() {
SD.begin(logPin);
///////// Create a new file //////////
char filename[] = "LOGGER00.CSV";
for (int i = 0; i < 100; i++) {
filename[6] = i/10 + '0'; // number the file
filename[7] = i%10 + '0'; //
if ( SD.exists(filename)==false ) { // only open a new file if it doesn't exist
logfile = SD.open(filename, FILE_WRITE);
break; // leave the loop!
}
}
}
void loop() {
// put your main code here, to run repeatedly:
logfile.println("Hello");
logfile.flush();
delay(1000);
}
\end{lstlisting}
\end{document}