pgm_read_byte doesn't work

Hi, I want to use the flash memory of my Arduino Nano 168, but somehow it gives strange results.

Here is the code:

 const prog_uint8_t BitMap[8] = {   // store in program memory to save RAM
        B10000000,
        B00000000,
        B00000000,
        B00000000,
        B00000000,
        B00000000,
        B00000000,
        B00000000,
 };
 
 void setup() 
{
  Serial.begin(9600);

}


void loop()
{

  Serial.print(BitMap[0]);
  Serial.print("    ");
  Serial.print(pgm_read_byte (&BitMap[0]));
  Serial.print("    ");
  
}

The values BitMapp[0] and pgm_read_byte (&BitMap[0]) are different.
BitMapp[0] is 128 (correct), but pgm_read_byte (&BitMap[0]) gives 144 and sometimes different depending on where i put the print command.

And why would one need pgm_read_byte at all. Why not just use BitMapp[0]?

thanks..

The way your array is defined appears to give strange results. This modified version works, and note that only the progmem access works, not the direct access.

byte PROGMEM BitMap  [8] = {  22, 33, 44, 55, 66, 77, 88, 99 };
 
void setup() 
  {
  Serial.begin(115200);
  }

void loop()
  {
  for (int i = 0; i < 8; i++)
    {
    Serial.print(BitMap[i]);
    Serial.print("    ");
    Serial.print(pgm_read_byte (&BitMap[i]));
    Serial.println ();
    }
  while (true);  // loop forever
  }

Output:

0    22
0    33
184    44
0    55
0    66
0    77
1    88
0    99

Thanks, Nick. If I change const to PROGMEM, then it works.