Hi,
I'm making a bluetooth device by simply connecting a bluetooth module to the Tx and Rx pins on an Arduino Mega. Right now I'm just sending characters Arduino->Android via BlueTerm on my Android phone and sending them Android->Arduino by coding a Serial.print("a") in the Arduino code, and this works fine.
Now for the next step.
In general for this application I have three bytes of data, and I need those three bytes sent as quickly as possible when a button is pressed, i.e. as low latency as possible.
However I want this to be arbitrary data, like in my case, three arbitrary bytes. I don't want to be sending characters like "a" , "b" , etc around willy-nilly, because it's hard to keep track of what command "a" corresponds to, and what command "b" corresponds to, and so forth. It seems much better to send these three bytes of data as bytes of data (not characters) and have one line in my Android code interpret it (e.g. maybe I want Android to add those three numbers represented by those bytes to three other numbers or something), than to write something like:
switch(characterInput) {
case ("a"): // do something
case ("b"): // do something else
//... etc
}
which is ugly and hard to keep track of what command the nondescript letter "a" corresponds to.
So, is there a better or lower latency way to do this than to send, e.g. Serial.print("111100001111000011110000")? Because this sends the 1's and 0's as characters instead of bytes.
Thanks