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

Lab 5 - Spencer Shulem

Page history last edited by Benjamin Tee 12 years, 7 months 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.

     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

B.

     3.

          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.

4.

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

 

     http://img844.imageshack.us/img844/9083/cimg5255.jpg

✔ Nice.

C.

2.

          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.

3. 

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

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

               if(myFile){

               myFile.println("ZOMG");

               myFile.close();

               }else{

               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.

  4.

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

lcd.write(dataFile.read());

}

dataFile.close();

}

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

else {

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

}

}

5. 

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. 

D. 

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.

 

/*

  Graphics

 

 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>

 

//LCD PINS

#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()

{  

  lcd.init();

  lcd.clear();

 

   pinMode(buttonPin, INPUT);

 

   Serial.begin(9600);

  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:

    return;

  }

  Serial.println("card initialized.");

   if(!SD.exists("Sketch.txt")){

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

    sketch.close();

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

    sketch.close();

  }

}

/* loop */

void loop() {

  Serial.println("Loading Image");

    lcd.clear();

    int numRows = 6;

    int numCols = 84;

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

 

    lcd.gotoXY(0,0);

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

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

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

        //Serial.println(lcd.lcd_buffer[i][j]);

      }

    }

 

  sketch.close();

  lcd.update();

  Serial.println("Click to continue");

  buttonState = digitalRead(buttonPin);

  while(buttonState == LOW){

    buttonState = digitalRead(buttonPin);

    delay(100);

  }

  Serial.println("Drawing");

  lcd.clear();

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

    delay(100);

  }

  Serial.println("Now saving image");

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

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

      sketch.write(lcd.lcd_buffer[i][j]);

    }

  }

  lcd.clear();

  Serial.println("Click to continue");

  buttonState = digitalRead(buttonPin);

  while(buttonState == LOW){

    buttonState = digitalRead(buttonPin);

    delay(100);

  }

}

 

 

 

 

Comments (0)

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