Hi, everyone. I'm trying to learn how to communicate serially between 2 Arduinos. I can send and receive PWM values, but I have not figured out how to send strings. I have 2 Arduino Mega 2560s. I want to be able to see the full character string in the serial monitor of Arduino1, but no matter what character string I send, I get only the last one to print to the monitor. How do I get the entire string to print?
Connections:
Arduino1 GND --> Arduino2 GND
Arduino1 rx3 --> Arduino2 tx3
Arduino1 tx3 --> Arduino2 rx3
Arduino1 --> Laptop via USB
Arduino1 (Base) Code:
void setup(){
Serial.begin(9600);
Serial3.begin(9600);
}
void loop(){
if (Serial3.available()){
char x = Serial3.read();
Serial.print(x);
}
}
Arduino2 (Remote) Code...ignore the commented out code:
void setup(){
Serial.begin(9600);
Serial3.begin(9600);
//Serial2.begin(4800);
//Serial2.write('!GPS');
}
void loop(){
/*if(Serial2.available()){
char x = Serial2.read();
Serial3.write(x);
}*/
char x = 'ABCDEFG';
Serial3.write(x);
}