Hello everyone,
New to Arduino and I like it a lot. I am trying to do something simple and have not gotten results I expect. I have two Unos. I want one to send hex data over to the other and have the other show it on the serial monitor. On the send Uno I have
byte keypad_data[] = {0x00};
void setup()
{
Serial.begin(115200);
}
void loop()
{
Serial.write((uint8_t*) keypad_data, sizeof(keypad_data));
delay(5000);
}
I am sending only 0x00 right now so that I can see what was going on during the serial read on the other side. The data that I want is something like this {0x10, 0x8D, 0x03, 0x05, 0x07, 0xFF, 0x10, 0x03}.
On the receive Uno I have
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX TX
void setup()
{
Serial.begin(115200);
Serial.println("Hey there");
mySerial.begin(115200);
}
void loop()
{
if (mySerial.available() > 0)
{
Serial.println(mySerial.read(),BIN);
}
}
When I do that I see in the serial monitor 10000000. Which is 0x80. I sent it 0x00. I read that serial.read() output is int. Here is a table of what I am seeing:
Send Receive(Serial.println(mySerial.read(),BIN)
0x00 10000000 -------> that is really 0x80
0x88 11001000 -------> that is really 0xC8
0xA8 11101000 -------> that is really 0xE8
0xF8 11111000 -------> that is 0xF8
Why is this happening? I can't seem to figure it out. I think its a data type thing but I am not sure. Sorry for being such a noob but this has me stumped. Thanks for you time.