I'm trying to send data from an Arduino to an Android device.
I saw an online guide for that which provided this code:
void setup()
{
Serial.begin(115200);
}
void loop()
{
byte msg[64];
int len = Serial.available();
if (len > 0)
{
len = Serial.readBytes((char*)msg, sizeof(msg)); // readBytes seems to need a char* not a byte*
Serial.write(msg, len);
}
}
I tried that example and it is working perfectly!
But when I put Serial.write("3");
in the setup loop after Serial.begin(115200);
it appears as question mark on my Android device,
I guess that I'm not sending it as a byte,
I searched online but without any luck.
loop()
doing a simple echo of what you type in the terminal emulator. Is that right? Everything works using the example above, but when you modify it to send the string "3" to the Android, kind of like a prompt, the "3" is not displayed correctly. Am I missing something? – dlu Jan 10 '16 at 22:47