Skip to main content
2 of 4
edited body
Alexander
  • 153
  • 1
  • 8

Sending number as byte throught serial

I'm trying to receive 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!

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 with not luck

any ideas ?

Alexander
  • 153
  • 1
  • 8