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

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

Part A

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

Using a multimeter, I tested that the voltage between VCC and GND is 3.29 Volts, which is approximately the desired voltage.

Part B

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?

About 14 characters; “I like the LCD”

About 6 lines can be written.

 

Part C

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

The connections that are in common are the ones for MOSI and SCLK. They are the same due to the SPI protocol. The connections should be left as is because this method is used to efficiently transmit/receive signals.

3a. 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();
   }

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

Create two new arrays, one containing the text string, "he who must not be named!" and the other containing the original text string. Create a new file which combines both arrays so that the "he who must not be named!" array is first and the original is second. 

 

4a. 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>
// On the Ethernet Shield, CS is pin 4. Note that even if it's not
// used as the CS pin, the hardware CS pin (10 on most Arduino boards,
// 53 on the Mega) must be left as an output or the SD library
// functions will not work.
#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);

const int chipSelect = 12;
 
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();
 
  File dataFile = SD.open("datalog.txt", FILE_WRITE);
   if (dataFile) {
    dataFile.println("he who must not be named!");
    dataFile.close();
   }
   
  dataFile = SD.open("datalog.txt");
 
  // if the file is available, write to the serial port:
  if (dataFile) {
    while (dataFile.available()) {
      lcd.writeChar(dataFile.read(), MODE_NORMAL);
    }
    dataFile.close();
  } 
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening datalog.txt");
  } 
}

void loop()
{

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

I had to import the LCD library and initialize the LCD in order to write each char to the LCD instead of the Serial monitor. 

 

*Note: The size of the circles/rectangles drawn on the Etch-a-Sketch depend on the amount of pressure applied to the FSR/bend sensor. 

 

Comments (1)

Benjamin Tee said

at 9:34 pm on Aug 15, 2012

Great job!

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