I'm trying to send some bytes to the Serial1 of my arduino MEGA. I'm sending this byte[] writebuffer = { 1, 2, 3, 4 }; but the output of Serial in arduino is 127 191 247 0.
I'm using a DB9, i have connected the GND to GND, Tx to Rx1 and Rx to Tx1 (connections from DB9 to arduino).
Here is my C# code:
SerialPort sepo = new SerialPort("COM6", 9600);
sepo.Open();
byte[] writebuffer = { 1, 2, 3, 4 };
sepo.Write(writebuffer, 0, writebuffer.Length);
sepo.Close();
And this is the arduino code:
void setup()
{
Serial.begin(115200);
Serial1.begin(9600);
}
void loop()
{
if(Serial1.available())
{
while(Serial1.available())
{
Serial.print((byte)Serial1.read());
}
Serial.println();
Serial1.println("recibi datos");
}
}