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

  • Get control of your email attachments. Connect all your Gmail accounts and in less than 2 minutes, Dokkio will automatically organize your file attachments. You can also connect Dokkio to Drive, Dropbox, and Slack. Sign up for free.

View
 

Alex - Lab5: Etch-a-Sketch

Page history last edited by Vivien Tsao 6 years, 11 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.