I'am trying to recive data from arduino to Android device
i saw an online guide for that he provided this code
void setup()
{
Serial.begin(115200);
}
void loop()
{
byte msg[64];
int len;
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!
i 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 with not luck
You may need to figure out weather you want to send a byte that represents the character "3" or a byte representing a binary 3. The print function should send a byte that represents the ascii character "3". You may also have issues on the android device and not the arduino. On the arduino side you can test using the serial monitor.
Your working program is overcomplicated, it copies input to output and tries to do that in 64 byte chunks.
Why your android app displays a question mark on reception of the character '3' only you now.
I would do the copy like that (including sending a '3' and a 0x03)