Having some trouble here getting this bit of code to execute on my Arduino Pro Mini...
if(EEPROM.read(EEMEMORYCHECK1) != eevalues[EEMEMORYCHECK1] && EEPROM.read(EEMEMORYCHECK2) != eevalues[EEMEMORYCHECK2]) //checking to see if this is the very first time we will update the EEPROM to the default values
{
for (int j = 0; j < EEPROM.length() ; j++)
{
EEPROM.write(j, 0);
}
for (int i = 0; i < EE_ARRAYSIZE; i++)
{
EEPROM.write(i, eevalues[i]); //writes all of the default values to the eeprom memory
}
}
Basically I'm storing my default values in the eevalues[] array that is initialized in my header.
What I'm trying to achieve is determine if this is the very first time I'm ever running this piece of code on my arduino. How I'm trying to do this is by comparing the first two bytes in the EEPROM to two integers at positions EEMEMORYCHECK1 and EEMEMORYCHECK2 within the array.
The logic here is that it will be very statistically unlikely (I think) that 'out of the box' those first two bytes in EEPROM were randomly assigned the integer values I chose. Therefore, this piece of code should run the very first time the code ever runs. The first for loop basically clears all of the EEPROM, and the second for loop then puts my default values from my array into EEPROM memory. The next time this if statement is run, those memorycheck integers will match and I won't keep writing over EEPROM memory (to keep from wearing it out).
Sounds nice in theory but I can't get the if statement to run... if I remove the && and the second comparison then it works... but then I have a much greater chance that my new arduino will have a matching value in EEPROM!
Any help would be great! Thanks!