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


Lab 5 - Spencer Shulem

Page history last edited by Benjamin Tee 9 years, 1 month ago

I finished lab on friday - except the video and have been working on the last part for the past 5 days and can't get it working 100%... I explain more at that part. Sorry. Thank you!



     A. How can you check you're board is now running at 3.3V? Check it out!

          By using a multimeter to check the voltage drop from power to ground



          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 you can write is 14 characters… and 6 collums.


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



✔ Nice.



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

               because the pins are shared between the MOSI and the SCK with the SD card with the graphical LCD,                nothing has to change.


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

               File myFile = SD.open("datalog.txt", FILE_WRITE);





               Serial.println("ERROR 5769j-0 has occurred in writing to the file.");


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 seek(); differently.


a. Post your code.

File dataFile = SD.open("datalog.txt", FILE_READ);

// if the file is available, write to the serial port:

if (dataFile) {

while (dataFile.available()) {





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

else {

lcd.println("Error opening datalog.txt");




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

I used instead of the commands from the EEPROM (.read() and write()) I used the SD.print() and SD.read(). Also used the same variable in the seek() for the SD card lib. 


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




I tried the past 5 days getting my board working long enough for a video... I can't... it works like 1/8th of the time and even then it's a little bit buggy. I finished the rest of the lab on friday, and have been trying to figure it out since. I will post my code for now and If I ever figure it out I will post a video.





 Runs a text-only demo on the Nokia 5110 LCD.


 The circuit:

 * Nokia 5110 Connected as follows:

LED   --> 50 Ohm   -->   3.3V

SCLK -->          Pin 1 (SCLK)

DN(MOSI)    -->          Pin 2 (MOSI)

D/C         -->          Pin 4

RST         -->          Pin 8

SCE         -->          Pin 9

GND         -->          GND

Vcc         -->          Pin 10


 By Andrew Lindsay (Adapted by Megan Wachs and edited by Matthew Seal and Akil Srinivasan)


 /*IF we are not using the Graphics or Bitmap capabilities

 of the LCD, save code space with these #defines*/


#include <nokia_5110_lcd.h>

#include <SD.h>



#define LCD_PWR   10

#define LCD_SCE   9

#define LCD_RESET 8

#define LCD_DC    4


int buttonPin = 18;

int buttonState = 0;


int potPin = 17;

int potPinTwo = 16;

double valx = 0;

double valy = 0;


File sketch;



const int chipSelect = 12;


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


void setup()





   pinMode(buttonPin, INPUT);



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

  // make sure that the default chip select pin is set to

  // output, even if you don't use it:

  pinMode(10, 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:



  Serial.println("card initialized.");


    sketch = SD.open("Sketch.txt", FILE_WRITE);


    sketch = SD.open("Sketch.txt", FILE_READ);




/* loop */

void loop() {

  Serial.println("Loading Image");


    int numRows = 6;

    int numCols = 84;

    sketch = SD.open("Sketch.txt", FILE_READ);



    for(int i = 0; i < numRows; i++){

      for(int j = 0; j < numCols; j++){

        lcd.lcd_buffer[i][j] = sketch.read();







  Serial.println("Click to continue");

  buttonState = digitalRead(buttonPin);

  while(buttonState == LOW){

    buttonState = digitalRead(buttonPin);





  int x = 42;

  int y = 24;

  buttonState = digitalRead(buttonPin);

  while(buttonState == LOW){

    lcd.setPixel(x, y, PIXEL_ON);

    valx = analogRead(potPin);

    valy = analogRead(potPinTwo);

    valx /= 1024;

    valy /= 1024;

    valx *= 2;

    valy *= 2;

    valx -= 1;

    valy -= 1;

    x += valx;

    y += valy;

    if(x > 84 || x < 0 || y > 48 || y < 0){

      x -= valx;

      y -= valy;


    buttonState = digitalRead(buttonPin);



  Serial.println("Now saving image");

  for(int i = 0; i < 84; i ++){

    for(int j = 0; j < 6; j ++){





  Serial.println("Click to continue");

  buttonState = digitalRead(buttonPin);

  while(buttonState == LOW){

    buttonState = digitalRead(buttonPin);








Comments (0)

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