Serial Port write send/receive varies at different baud rate

FeiFei
edited January 2018 in Arduino

Hello,

I am trying send one "1" to bluetooth connect with Arduino Mega 2560, send/receive works correctly when baud rate is 9600, but at other baud rate. For example, I set the baud rate to 38400, Arduino, receives 78 and 80, at 19200, I receives 6 and F8.

Bluetooth HC-05 connected to Serial2. Processing Code:

    void mouseReleased() {
      if(mouseX>50 && mouseX<200 && mouseY>100 && mouseY<150){
        myPort.write("1"); 
      }
    }

Arduino Code:

    void loop(){
      if (Serial2.available()>0){
        Serial.println(Serial2.read(),HEX);
        delay(500);
      }
    }

Any help is highly appreciated.

Regards,

Fei

Tagged:
Sign In or Register to comment.