Hi all,
As always, I'll keep it brief for your time.
Goal: to send a 10bit number, in the binary form, to the serial monitor (with all the leading zeros intact).
Code:
void setup () {
Serial.begin (9600);
}
void loop () {
byte x = 0b1000000000;
for (int i = 9; i >= 0; i--) {
Serial.print (bitRead (x, i));
}
Serial.print ("\n");
delay (1000);
}
Reality:
I'm getting this (copy and pasted from serial monitor):
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
If I recall correctly, I can only define a 1 byte binary in the Arduino environment. If this in fact is the issue, how can I "properly" display a 10bit binary number on the serial monitor?
Thank you.