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

Report - Lab 5

Page history last edited by Benjamin Tee 11 years, 8 months ago

a. How can you check that your board is now running at 3.3V? Check it out!

Using a voltmeter between the vcc and the ground pins.


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

The longest message for one line will be a message of 14 letters (like "want cold beer"), and you can write six lines.

 


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


a. Why is this? What can (or should) you do about it?

Because we are using SPI communication, so the devices are connected to the same bus, but they got a dedicated pin to select the one we want to talk to.


a. 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 thebeginning of the file (without over-writing the current contents).

We would need 2 files references, this file and a new one. Write what we want in the new one, and then write everything from the old one in the new one. Then delete the old and rename the one.


a. Post your code.

/*

  SD card file dump

 

 This example shows how to read a file from the SD card using the

 SD library and send it over the serial port.

 

 created  22 December 2010

 

 This example code is in the public domain.

 

 */

 

#include <SD.h>


const int chipSelect = 12;
#define NO_GRAPHICS
#define NO_BITMAP
#include <nokia_5110_lcd.h>

//LCD PINS
#define LCD_PWR   10
#define LCD_SCE   9
#define LCD_RESET 8
#define LCD_DC    4

Nokia_5110_lcd lcd(LCD_PWR, LCD_DC, LCD_SCE, LCD_RESET);
 

void setup()

{

  Serial.begin(9600);

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

 

  // 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.");

   lcd.init(40); //parameter is contrast value, between 0 [low] and 127 [high]
  lcd.clear();

  // 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 the serial port:

  if (dataFile) {


    for (int i = 0 ; i < 84 ; i++) {
      lcd.writeChar(dataFile.read(), MODE_NORMAL);
//      Serial.write(dataFile.read());

    }

    dataFile.close();
  }  

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

  else {

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

  }

}

 

void loop()

{

}


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

Include the libraries, initialize the SD card.

Then open the file, use the seek function, to go to the desired byte, before the EEPROM functions. And change the EEPROM read()/write(); to the FILE read()/write();


a. Upload video of your Etch-a-Sketch in action!

 

 

 

 

Comments (0)

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