Hello,
I am trying to send serial data from an UNO (pin 0 , pin1) to a Mega Serial1.
No luck so far.
I have Rx to Tx and Tx to Rx.
Both baud rates are the same.
I tried connecting the grounds together to see if that was the problem.
The code on the reciever (mega) looks like this:
loop(){
while(! Serial1.available){
// just wait
}
while(Serial1.avaiable){
int input = Serial1.read();
delay(60);
Serial.println(input);
}
just as a simple test, you could try the below code on both the uno and mega. Disconnect the wire between the uno rx pin and mega tx pin to prevent interference during the test, then send something using the uno serial monitor and see if it is echoed back to the uno serial monitor and appears on the mega serial monitor.
// zoomkat 7-30-11 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later
String readString;
void setup() {
Serial.begin(9600);
Serial.println("serial test 0021"); // so I can keep track of what is loaded
}
void loop() {
while (Serial.available()) {
delay(2); //delay to allow byte to arrive in input buffer
char c = Serial.read();
readString += c;
}
if (readString.length() >0) {
Serial.println(readString);
readString="";
}
}
Thanks everyone. Another case of cockpit error.
To begin with I didn't realize the grounds needed to be connected between the two Arduinos. After correcting that I still had another problem. I had the serial port numbers mixed up. I assumed Serial1 was on the lower numbered pins and Serial3 was on the higher numbers. WRONG.
Funny how things suddenly work when you RTM.
-Steve