Tried some serial communication using the following code with arduino mega 2560. The serial output was monitored.
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
Serial2.begin(9600);
Serial3.begin(9600);
}
void loop()
{
Serial.write("HelloWorld")
Serial1.write("HelloWorld")
Serial2.write("HelloWorld")
Serial3.write("HelloWorld")
}
data from serial0 received as HelloWorld
data is received from serial1/serial2/serial3 but in some unknown format.
the output received in ascii format is {BC}{D5}{27}{27}{21}{51}{21}#ESC{27}{37}#NUL
Is there some configurations needed for using these ports for serial communication?
I assume you used level converters (max232) or ftdi cables to connect 1, 2 and 3 to the computer.
I can't check but try print instead of write.
Also tried using serial.print. it do not make any difference.
have connected the board to the PC via RS232 cable. is this causing any problem?
can you give some alternatives to solve.
RS232 uses 12 volt levels and the signal is inverted.
ttl. 0V 5V
rs232 12V -12V
Use max232 or similar or use ftdi cables.
I tried both. data is receiving in the serial0 in right format.
but is corrupted in the other ports. i use a usb to serial cable for the connection from arduino to pc
void loop()
{
Serial.write("HelloWorld")
Serial1.write("HelloWorld")
Serial2.write("HelloWorld")
Serial3.write("HelloWorld")
}
Lots of missing semicolons there. Just to be sure, may we see the actual code you're trying? The code you pasted surely won't compile.
the problem was resolved by using a USB to RS232 board in between arduino and PC.
the error was whlie trying to read the serial data directly from the RX1/TX1 without a MAX in between.
thanks for the suuport.
here is the code I used.
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
Serial2.begin(9600);
Serial3.begin(9600);
}
void loop()
{
Serial.write("HelloWorld");
Serial1.write("HelloWorld");
Serial2.write("HelloWorld");
Serial3.write("HelloWorld");
}