Divergence in reading

Asked

Viewed 30 times

1

I made a sketch for Arduino MEGA, where receives data by Serial2 and displays in Serial, the communication happens but the byte sent is not the same as the received, for example:

Send 0x01, receive 0x7F Send 0x99, receive 0x33

    void setup()
    {
      Serial.begin(9600, SERIAL_8N1);   //Monitor
      Serial2.begin(9600, SERIAL_8N1);  //Leitor

      Serial.println("Waiting...");
    }

    void loop()
    {
      byte data;

      if ( Serial2.available() ) {
        Serial.println("Leitor...");

        do { 
          data = Serial2.read();

          Serial.print("0x");
          Serial.println(data, HEX);
        } while (Serial2.available());

      }
}

I tried to change the configuration to 8N2, 7N1 among others but the serial sending as in the image below:

inserir a descrição da imagem aqui

It is not the first time that I try to read something by another MEGA serial that is not zero and the same happens.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.