stickyBUG Code

// import library...
#include <SD.h>

// sd card chip select pin - this is pin 10 for the stickyBUG
const int chipSelectPin = 10;

// program initialisation...
void setup()
{
 // open serial communications and wait for port to open:
  Serial.begin(9600);
  Serial.println("Initialising SD card, please wait...");

  // see if the card is present and can be initialized:
  pinMode(chipSelectPin, OUTPUT);
  if (!SD.begin(chipSelectPin)) {
    Serial.println("Card failed or card not inserted");
    return;
  }
  Serial.println("Card is initialised");

  // open the file and write 10 numbers, then close the file...
  Serial.println("Opening datalog file...");
  File dataFile = SD.open("datalog.txt", FILE_WRITE);
  if (dataFile) {
     Serial.println("File opened, writing data...");
     for (byte i = 0; i < 10; i++) {
       dataFile.print("the index number is : ");
       dataFile.println(i, DEC);
     }
     dataFile.close();
     Serial.println("File closed");
  } else {
    Serial.println("Unable to open file");
  } 
}

// main program loop...
void loop()
{
}