Datasheet
to kick start the logging. If you have this on you basically can't have it run away from
the computer so we'll keep it off (set to 0) for now. If you want to turn it on, set this to
1
The other defines are easier to understand, as they are just pin defines
redLEDpin is whatever you connected to the Red LED on the logger shield
greenLEDpin is whatever you connected to the Green LED on the logger shield
photocellPin is the analog input that the CdS cell is wired to
tempPin is the analog input that the TMP36 is wired to
Objects and error()
Next up we've got all the objects for the RTC, and the SD card chip select pin. For all our
shields we use pin 10 for SD card chip select lines but Ethernet shields use pin 4
Next is the error function, which is just a shortcut for us, we use it when something Really
Bad happened, like we couldn't write to the SD card or open it. It prints out the error to the
Serial Monitor, turns on the red error LED, and then sits in a while(1); loop forever, also
known as a halt
Setup
RTC_DS1307 RTC; // define the Real Time Clock object
// for the data logging shield, we use digital pin 10 for the SD cs line
const int chipSelect = 10;
// the logging file
File logfile;
void error(char *str)
{
Serial.print("error: ");
Serial.println(str);
// red LED indicates error
digitalWrite(redLEDpin, HIGH);
while(1);
}
void setup(void)
© Adafruit Industries https://learn.adafruit.com/adafruit-data-logger-shield Page 60 of 68