0% found this document useful (0 votes)
26 views1 page

1 SD Card Example: #Include

This document contains an Arduino code snippet that writes log data to an SD card. It uses the SD library to begin accessing the SD card using pin 10. The code creates a new CSV file numbered from 00 to 99 to store the log data. Each loop, it prints "Hello" to the open logfile and flushes the output before waiting 1 second to repeat.

Uploaded by

cristian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views1 page

1 SD Card Example: #Include

This document contains an Arduino code snippet that writes log data to an SD card. It uses the SD library to begin accessing the SD card using pin 10. The code creates a new CSV file numbered from 00 to 99 to store the log data. Each loop, it prints "Hello" to the open logfile and flushes the output before waiting 1 second to repeat.

Uploaded by

cristian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

1 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.

1 #include <SD.h>
2
3 File logfile;
4 byte logPin = 10;
5
6 void setup() {
7 SD.begin(logPin);
8
9 ///////// Create a new file //////////
10 char filename[] = "LOGGER00.CSV";
11 for (int i = 0; i < 100; i++) {
12 filename[6] = i/10 + ’0’; // number the file
13 filename[7] = i%10 + ’0’; //
14 if ( SD.exists(filename)==false ) { // only open a
new file if it doesn’t exist
15 logfile = SD.open(filename, FILE_WRITE);
16 break; // leave the loop!
17 }
18 }
19 }
20
21 void loop() {
22 // put your main code here, to run repeatedly:
23 logfile.println("Hello");
24 logfile.flush();
25 delay(1000);
26 }

You might also like