This simple program is suppose to print out powers of two using the Bitshift operator. I’m expecting an output of 1, 2, 4, 8, 16, 32, but instead get 0, 1, 2, 4, without the 8, 16 and 32.
I must be overlooking something really simple. Any suggestions?
void setup() {
Serial.begin(9600);
}
void loop() {
for (int x = 0; x < 6; x = (1 << x)) {
Serial.print(x);
Serial.print(", ");
}
Serial.println();
delay(1000);
}