Im playing around with the internal eeprom. I wrote a simple code to check the value of the first address of eeprom. If its either a 0 or 255, check the analog pin and write that new value to eeprom. I get a different value every time that eeprom address is checked. where am i messing up?
The values, as seen by the serial monitor, are all over the place, ie. 102, 81, 100, 105...
Why does it keep changing?
#include <EEPROM.h>
byte calibration;
byte newcalibration;
void setup()
{
Serial.begin(9600);
#define address 0
#define analogPin 3
}
void loop()
{
calibration = EEPROM.read(address);
if (calibration = 0 || 255)
{
delay(100);
calibration = analogRead(analogPin) / 4;
EEPROM.write(address, calibration);
delay(100);
//calibration = EEPROM.read(address);
}
Serial.print(address);
Serial.print("\t");
Serial.print(calibration);
Serial.println();
delay(1000);
}