Thursday, May 5, 2011

Lab 4 Part 1

It's been a while since either Paul or I posted! Senior design, post-graduation planning, etc kind of got in the way. But anyway, the semester is over and BE 470 is done, and we realized we had a huge backlog of posts that we had for the world to see and enjoy. So here we go! Paul and I are going to try and break these up into manageable chunks so you guys don't see this and get supremely frustrated trying to get through the code!

So the first part of Lab 4 was experimentation with EEPROM (Electrically Erasable, Programmable, Read-Only Memory). It is essentially the memory that accompanies the Arduino and is an excellent way to STORE data. However, even though you can read the data from the EEPROM x928142984612 times, one has to be careful in how many times he/she writes data onto this type of memory, because it can get worn out pretty quickly! Anyway, shown below is the code we used to write and read from EEPROM.

#include

int address1 = 1;
int address2 = 2;
int address3 = 3;
int address4 = 4;

int value1 = 0;
int value2 = 2;
int value3 = 4;
int value4 = 6;

int output1;
int output2;
int output3;
int output4;

void setup()
{
Serial.begin(9600);
EEPROM.write(address1,value1);
EEPROM.write(address2,value2);
EEPROM.write(address3,value3);
EEPROM.write(address4,value4);
}

void loop()

{
output1 = EEPROM.read(address1);
output2 = EEPROM.read(address2);
output 3 = EEPROM.read(address3);
output4= EEPROM.read(address4);

Serial.println(output1);
Serial.println(output2);
Serial.println(output3);
Serial.println(output4);

}

No comments:

Post a Comment