Hi,
I just came across a problem when reading values from an array which was stored in ROM by "PROGMEM" approach. Although all the values stored are "0", it was read as "65535" and other values. (Please see the screenshot below)
This problem did not come up when I deleted "PROGMEM", using RAM to store the array. Could anyone tell me what is going on with it and how should I handle that?
This is the way how I defined the array:
(I tried int, long, char, but it didn't work)
const long C_YX [2][84] PROGMEM = {
{0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
};
This is the way how I read the values:
int X_INDEX; int Y_INDEX;
for (Y_INDEX=0; Y_INDEX<2; Y_INDEX++) {
for (X_INDEX=0; X_INDEX<84; X_INDEX++) {
Serial.print (X_INDEX);
Serial.print (",");
Serial.println (Y_INDEX);
Serial.println (C_YX[Y_INDEX][X_INDEX]);
Serial.println ("-----------");
delay(1000);
}
}