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

View
 

sethuLab5

Page history last edited by SETHU KOVENDHAN BOOPATHY JEGATHAMBAL 7 years, 2 months ago

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?

 

     Using standard font we can write a line of 14 characters including space character.There can be upto 6 lines in it.

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

We have to include this code in the program.

 

dataFile.write("whatever");

 

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

 

  if (dataFile) {

    while (dataFile.available()) {

      newstr=newstr+dataFile.read();

    }

     ai=ai+newstr

     datafile.seek(0)

    dataFile.print(ai);

    Serial.write(ai);

 

where ai is our string to be inserted. 

 

 

a. Post your code.

 

#include <SPI.h>

#include <SD.h>

#include <Adafruit_GFX.h>

#include <Adafruit_PCD8544.h>

Adafruit_PCD8544 display = Adafruit_PCD8544(7,6,5,-1,-1);

 

char ai[]="whatever";

int i;

 

//On the Arduino Micro, the SS pin is defined in software as pin 17. 

const int chipSelect = 17;

 

void setup()

{

  display.begin();

  display.setContrast(50);

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

    while (dataFile.available()) {

      newstr=newstr+dataFile.read();

    }

    ai=ai+newstr

    datafile.seek(0)

    dataFile.print(ai);

    Serial.write(ai);

    display.setCursor(0, 0);

    display.print(ai);

    dataFile.close();

  }  

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

  else {

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

  } 

}

 

void loop()

{

}

 

5. Modify your data logger code from last lab so that you can write to the microSD card. If you took apart your data logger already, make the changes to your old code that you would need to make it write to the SD card.

 

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

 

Read the value from the sensor value and use "dataFile.write(analogRead(A0))" and later it can be dispayed using "data file.read()" and display it in serial monitor or graphic LCD

 

Part D. Create an Etch-a-Sketch!

http://www.youtube.com/watch?v=UVJ-dgSlwOMc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Comments (3)

Vivien Tsao said

at 3:38 pm on Aug 14, 2013

please email me when you finish this lab.

SETHU KOVENDHAN BOOPATHY JEGATHAMBAL said

at 1:56 am on Aug 15, 2013

I finished lab5

Matt Galla said

at 5:42 am on Aug 20, 2013

Looks good!

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