| 
  • 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
 

Alex - Lab5: Etch-a-Sketch

Page history last edited by Vivien Tsao 10 years, 8 months ago

LAB 5 - Make an Etch-a-Sketch!

 

Part A. Graphical LCD

 

a. With the standard font, what is the longest message you can write across one line of the display? How many lines can you write?

We can write 14 characters message in 6 lines.

b. Upload a photo of your personal logo, shown on your LCD screen, to your Lab 5 page.

 

✓ :]

Part B. microSD Card

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

#include <SPI.h>

#include <SD.h>

 

const int chipSelect = 17;

 

void setup()

{

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

  Serial.begin(9600);

  delay(1000);

  }

 

  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", FILE_WRITE);

 

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

  if (dataFile) {

    dataFile.println("You shall not pass!");

    dataFile.close();

    Serial.println("The file has been modified");

  }  

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

  else {

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

  } 

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

 if (dataFile)

 {

   Serial.println("Modified File: ");

   while(dataFile.available())

   {

     Serial.write(dataFile.read());

   }

   dataFile.close();

 }

 else

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

}

void loop()

{

}

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

 

I would use functions seek() and position() to start writing on position 0 of file.

Part D. Create an Etch-a-Sketch!

http://www.youtube.com/watch?v=2Zn4L1z8VOI 

Comments (1)

Vivien Tsao said

at 3:35 pm on Aug 14, 2013

Good.

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