I need to work with bit, and so i choice pgm style.
Why this code is not working as expected?
#include <avr/pgmspace.h> //for pgm_read_byte
const prog_uint8_t wcode[9] = { // store in program memory to save RAM
B10010000,
B11100000,
B01000010,
B11010000,
B00000000,
B00000000,
B01100100,
B00000101,
B10100000 //last 4 bit is not used
};
void setup() {
Serial.begin(9600);
}
void loop() {
for (byte x=0; x<9; ++x) {
byte data = pgm_read_byte (&wcode[x]); // fetch data from program memory
for (byte y=0; y<8; ++y) {
if (data & (1<<y)) {
Serial.print("1");
} else {
Serial.print("0");
}
}
Serial.println("");
}
Serial.println("");
Serial.println("");
delay(15*1000);
}
This code return this bit sequence
00100000
10000100
01101001
00010011
00001100
10001011
10100000
10000010
11101111