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

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

JishnuDatta_Lab(5)

Page history last edited by Jishnu Datta 10 years, 8 months ago

a.

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.

 

b.

 

 

 

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:

  Serial.begin(9600);

  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:

    return;

  }

  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) {

     display.begin();

     display.clearDisplay();

     display.setContrast(50);

     display.write(dataFile.read());

     display.display();

    dataFile.close();

  }  

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