Lab5


Richard Zajac

Press Play EE-47

Lab 5 – Report

B-1.a

I determined that my board was running at the correct voltage (3.3V) by testing the voltage and ground pins on the teensy with a multimeter.

Part B

 

B-3.a

I am able to write six lines of text to the display, sixteen [small] characters wide.

 

B-4.a

Photo below:

 

C2a: Even though the devices ‘double up’ on the same pin, I can simply just connect to an adjacent pin on the breadboard, and let them share the newly created bus. (Just like those buss bars used by industrial battery-backup systems).

 

C3a.

 

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

if(dataFile){

dataFile.println();

 

dataFile.print(“Not Slytherin Eh?”);

dataFile.close();

}

 

 

C-3b.

 

So what I did was make another file, so put the Gryffindor blurb in, then transfer the datalog file over into the new file.

 

 

/*

SD card datalogger

This example shows how to log data from three analog sensors

to an SD card using the SD library.

The circuit:

* analog sensors on analog ins 0, 1, and 2

* SD card attached to SPI bus as follows:

** MOSI - pin 11

** MISO - pin 12

** CLK - pin 13

** CS - pin 4

created 24 Nov 2010

updated 2 Dec 2010

by Tom Igoe

This example code is in the public domain.

 

Modified by Richard Zajac 'of the Gryffindor House' -- EE47 Stanford U - 2011

*/

#include <SD.h> const int chipSelect = 11;

// 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. byte phrase; //variable used to read content from datalog.txt char phrases[1000]; //where we can store "phrase" int i = 0; //This is where the 'other than Gryffindor phrase' is stored

File newFile;

void setup()

{ 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: if (!SD.begin(chipSelect))

{ Serial.println("Card failed, or not present"); // don't do anything more: return;  }   Serial.println("card initialized.");   // Makes new file for blank-card use   if(!SD.exists("new.txt"))

{     newFile = SD.open("new.txt", FILE_WRITE);     newFile.print("Not Slytherin, Eh?");     newFile.println();   }   newFile.close();   File dataFile = SD.open("datalog.txt");   if (dataFile) {     while (dataFile.available())

{       phrase = (dataFile.read());       Serial.write(phrase);       phrases[i] = phrase;       i++;     }      Serial.println(" ");      //Serial.println(i);      dataFile.close();   }   // if the file isn't open, pop up an error:   else {     Serial.println("error opening datalog.txt");   } //Transfers data (buffer) from the 'newer' file

  newFile = SD.open("new.txt", FILE_WRITE);

  for(int j=0;j<i;j++)

{     newFile.write(phrases[j]);   }   newFile.close(); //allows for there to be feedback from 'new' file

  //Serial.println("Redundancy Alert");

  newFile = SD.open("new.txt");  

if (newFile) {     while (newFile.available())

{       Serial.write(newFile.read());     }     Serial.println("Completed");     newFile.close(); }

else

{ Serial.print("Operation Complete"); } }

 

C-4.a

 

/*

SD card datalogger

This example shows how to log data from three analog sensors

to an SD card using the SD library.

The circuit:

* analog sensors on analog ins 0, 1, and 2

* SD card attached to SPI bus as follows:

** MOSI - pin 11

** MISO - pin 12

** CLK - pin 13

** CS - pin 4

created 24 Nov 2010

updated 2 Dec 2010

by Tom Igoe

This example code is in the public domain.

 

Modified by Richard Zajac 'of the Gryffindor House' -- EE47 Stanford U - 2011

*/

#include <SD.h>

#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 = 11;

// 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. byte phrase; //variable used to read content from datalog.txt int i = 0; //This is where the 'other than Gryffindor phrase' is stored

int j;

intk;

void setup()

{ 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: if (!SD.begin(chipSelect))

{ Serial.println("Card failed, or not present"); // don't do anything more: return;  }   Serial.println("card initialized.");  

  File dataFile = SD.open("datalog.txt");   if (dataFile) {     while (dataFile.available())

{       phrase = (dataFile.read());       Serial.write(phrase);       phrases[i] = phrase;       i++;     }      dataFile.close();   }   // if the file isn't open, pop up an error:   else {     Serial.println("error opening datalog.txt");   } //Transfers data (buffer) from the 'newer' file

lcd.init();

}

void loop(){

char words;

char letters;

k = 1;

for(j=0;j<i;j++){ words = phrases[j]; lcd.writeChar(words,MODE_NORMAL);

//Clear screen once filled up to max characters, or 84 if(j==84*k){ lcd.clear();

k++; }

delay(250); } }

 

C-5.a

 

So in order to make this work, I needed to do several things. I Initialized the SD card, and by extension, I had to initialize the corresponding library. I went ahead and made another file to store this all in. So to EEPROM write, I just write to that file I made.

 

Part D-5.a

 

Video in the Hall of Fame