I wrote the code below and the result is not what I expected at all! I'm not sure why it's happening!
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
const uint8_t pat[] PROGMEM = {
0xff,
0x00,
0xff,
0x00,
0xff,
0x00,
0xff,
0x66
};
void loop() {
delay(100);
Serial.println(sizeof(pat));
for (int i=0; i<8; i++){
Serial.print(pat[int(i)],HEX);
}
Serial.println("");
Serial.print(pat[0],HEX);
Serial.print(pat[1],HEX);
Serial.print(pat[2],HEX);
Serial.print(pat[3],HEX);
Serial.print(pat[4],HEX);
Serial.print(pat[5],HEX);
Serial.print(pat[6],HEX);
Serial.print(pat[7],HEX);
Serial.println("");
while(true);
}
the output is surprisingly this:
8
008000010
FF0FF0FF0FF66
What is compiler doing in the background but it seems to be messing things up really bad! The loop should be doing the exact same thing as manually writing that code over and over but it's not! How can I fix the loop?
Serial.println("--------------");