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