0

I want to code an if statement in the setup of my arduino uno project, the pseudocode would be something like this:

If the nth slot of EEPROM memory is not empty, then do something.

So what I did is:

if((EEPROM.read(n) != 0)

Thinking that the 8 bit sequence initialized to 0 would be equal to the integer 0, but something is clearly off because the statement is always true.

Thanks for your time!

zurg
  • 13
  • 4

1 Answers1

0

Ok i did a simple test reading all the EEPROM with this script:

#include <EEPROM.h>

int a = 0;
int value;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  value = EEPROM.read(a);

  Serial.print(a);
  Serial.print("\t");
  Serial.print(value);
  Serial.println();

  a = a + 1;

  if (a == 512)
    a = 0;

  delay(500);
}

And I found out that EEPROM is initialized to 11111111 so 255, still don't understand why but ok, problem solved!

zurg
  • 13
  • 4