Hi all,
I am trying to use the Serial1, Serial2 and Serial 3 (pin 14-19) of my arduino 2560 to read digital signal of my lab's instruments. I used a RS232 to TTL board (MAX3232) to convert the digital signals from the instruments, however there is no response.
I did some simple test.
i sent out some letters through the MAX3232 and the used a rs232 to usb converter to convert the signal and my computer can receive the letters and displayed using the arduino software. however, when i send back some letters, the ardunio could not receive.
Here is the code:
void setup(){
Serial.begin(9600);
Serial1.begin(9600);
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
}
void loop(){
// to display something in arduino software
Serial1.write("Waiting Signal....");
Serial1.println("");
delay(500);
// to see if mega2560 recieve anything from the computer
if (Serial1.available()){
Serial1.println("");
int aaa = Serial1.read();
Serial1.println(aaa);
delay(500);
digitalWrite(13, HIGH);
}
}
actually i received some random number for the variable "aaa" and the LED always turned on.
Do you know how can I change the code so that I can receive digitial signal from rs232 using max3232 and the mega 2560 board.
Hope you can help!