I am trying to use the Serial Monitor to send commands via my RF Link (Ciseco SRF). The RF seems to work great.
My problem is that the Serial Monitor assumes ASCII, and I want to use binary, or at least utilize ASCII characters to simulate the binary portion of my message.
For example, I want to send a binary 00000100, so the ASCII EOT character is 00000100 (or HEX 04). But how do I send an EOT character using the Serial Monitor?
The below test code might do something close to what you are trying to do.
//zoomkat serial echo test 7-31-2011
char c; // incoming serial data
void setup() {
Serial.begin(9600); // set serial port at desired value
Serial.println("serial echo test 0021"); // echo test
Serial.println();
}
void loop() {
if (Serial.available() > 0) { // check for serial buffer input
c = Serial.read(); // read the incoming byte:
Serial.println(c); // print the input
//select an output format
Serial.println(c, DEC); // print as an ASCII-encoded decimal
Serial.println(c, HEX); // print as an ASCII-encoded hexadecimal
Serial.println(c, OCT); // print as an ASCII-encoded octal
Serial.println(c, BIN); // print as an ASCII-encoded binary
Serial.println();
//Serial.println(); // print new line for better reading
}
}
Farmboy:
I am trying to use the Serial Monitor to send commands
I want to use binary, or at least utilize ASCII characters to simulate the binary portion of my message.
Why send the commands in binary?
I'm not against sending binary data but if I wanted to do that I would write a PC program using Python, for example.
If you just want to send different commands the upper and lower case characters provide 52 options. The Arduino can easily use a look-up table to figure out the binary value associated with a character.