I'd like to send the arduino a 0xC0 and see it come out in the binary option correctly.
Or send it as dec 192 and have the binary option show it correctly as 11000000.
byte myByte;
void setup(void){
Serial.begin(9600); // begin serial communication
}
void loop(void) {
if (Serial.available()>0) { // there are bytes in the serial buffer to read
while(Serial.available()>0) { // every time a byte is read it is expunged
// from the serial buffer so keep reading the buffer until all the bytes
// have been read.
myByte = Serial.read(); // read in the next byte
}
Serial.println(myByte, DEC); // base 10, this is the default
Serial.println(myByte, HEX); // base 16
Serial.println(myByte, OCT); // base 8
Serial.print(myByte, BIN); // base 2
Serial.write(myByte); // ASCII character
Serial.println(); // carriage return
delay(100); // a short delay
}
}
I modified it to spit out one line but as you know it was the same result...just on one line no spaces of not what of I want.
I'd like to type in 0xC0 and see the right values. Or some how type in 11000000 and see the right value.
The input from the monitor is in ASCII so you type in a 5 and you get the hex value 0x35.
So if you type in 0xC0 you get four bytes plus any return character you have set.
Grumpy_Mike:
The input from the monitor is in ASCII so you type in a 5 and you get the hex value 0x35.
So if you type in 0xC0 you get four bytes plus any return character you have set.
Thank you.
I see, it lists the 5s hex as 35, no 0x prefix.
Why for the Bin of 5 does it list it without the leading zeros and puts the 5 at the end? 1101015? I guess I was expecting 00110101.
You are probably grumpy from noobs asking noob questions lol
The 0X prefix is only for us humans to see what sort of number it is. It is only one of a number of standard prefixes or post fixes you can use,
Other ways of showing the ASCII value of 5 are
&35
0H35
35H
35^
However if you want to display this then you have to output the extra yourself.