Rev 2201 Rev 2241
Line 1... Line 1...
1 /* 1 /*
2 SD card datalogger 2 SD card datalogger
3 3
4 This example shows how to log data from three analog sensors 4 This example shows how to log data from three analog sensors
5 to an SD card using the SD library. 5 to an SD card using the SD library.
6 6
7 The circuit: 7 The circuit:
8 * analog sensors on analog ins PC0, PC1, and PC2 8 * analog sensors on analog ins PC0, PC1, and PC2
9 * SD card attached to SPI bus as follows: 9 * SD card attached to SPI bus as follows:
10 ** MOSI - PB3 10 ** MOSI/CMD - PB3
11 ** MISO - PB4 11 ** MISO/DAT0 - PB4
12 ** CLK - PB5 12 ** CLK - PB5
13 ** CS - PD4 13 ** CD/DAT3 - PD4
14 -  
15 created 24 Nov 2010 -  
16 updated 2 Dec 2010 -  
17 by Tom Igoe -  
18 -  
19 This example code is in the public domain. -  
20 14
21 */ 15 */
22   16  
23 #include <SD.h> 17 #include <SD.h>
24 const int chipSelect = 4; 18 #define chipSelect 4
25   19  
26 void setup() 20 void setup()
27 { 21 {
28 Serial.begin(9600); 22 Serial.begin(9600);
29 Serial.print("Initializing SD card..."); 23 Serial.print("Initializing SD card...");
Line 44... Line 38...
44   38  
45 void loop() 39 void loop()
46 { 40 {
47   41  
48 // make a string for assembling the data to log: 42 // make a string for assembling the data to log:
49 String dataString = "$"; 43 String dataString = "$LOG";
50 delay(100); 44 delay(100);
51 dataString += String(count); // print number of measurement 45 dataString += String(count); // print number of measurement
52 dataString += ","; 46 dataString += ",";
53   47  
54   48