I encounter problems with using stuff in PROGMEM flash memory. To make things easier to see I have written a small sketch which shows the problem.
const PROGMEM byte data[] =
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
};
void setup()
{
int i;
byte displayInt;
Serial.begin( 115200 );
Serial.println( "Test" );
for( i=0; i<8; i++ )
Serial.println( pgm_read_byte( data[i] ), HEX );
Serial.println( "------" );
for( i=0; i<8; i++ )
Serial.println( pgm_read_byte( data+i ), HEX );
}
void loop()
{
}
The first loop produces garbage, the 2nd one correct values. Why?