• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.



Page history last edited by Jishnu Datta 7 years, 1 month ago


I can fit around fit 14 per on the display. I can only fit 6 lines on the display.

Therefore I can only fit a total of 14 * 6 = 84 characters on the display.






3a. Include the code that you had to insert to do this in your lab writeup.

 File dataFile = SD.open("datalog.txt", FILE_WRITE);  
if (dataFile) {    
dataFile.println("He who must not be named");   
dataFile.close();   }


b. Explain what would you do differently (or show us your code!) to insert the same text string, but at the beginning of the file (without over-writing the current contents).

To place the same text string at the beginning of the file, I would save whatever was on the SD card, then I would clear the SC card. After that I would paste the string first, followed by the previously saved information which was on the SD.


4a. Post your code.

My setup part of the code:


void setup()


 // Open serial communications and wait for port to open:


  delay(1000); //this 1 second delay isn't strictly speaking necessary, but it seems to smooth over the USB serial monitor a bit. 

   while (!Serial) {

    ; // wait for serial port to connect. Needed for Leonardo only



  Serial.print("Initializing SD card...");

  pinMode(17, OUTPUT); //set SS pin as output. 


  // see if the card is present and can be initialized:

  if (!SD.begin(chipSelect)) {

    Serial.println("Card failed, or not present");

    // don't do anything more:



  Serial.println("card initialized.");


  // open the file. note that only one file can be open at a time,

  // so you have to close this one before opening another.

  File dataFile = SD.open("datalog.txt");


  // if the file is available, write to it:

  if (dataFile) {








  // if the file isn't open, pop up an error:

  else {

    Serial.println("error opening datalog.txt");





5a. Tell us what you had to change to make this work.

I would replace the EEprom functions like read and write with the SD Card.

Comments (1)

Vivien Tsao said

at 4:24 pm on Aug 14, 2013

? incomplete.

You don't have permission to comment on this page.