Hi there,
We're eventually writing code that will send numbers down a wire and use them to do stuff with, but for now, we're just testing the serial connection from one Uno to another. We have the Tx Uno loaded with simple code to simply send out a number, and the Rx Uno loaded with simple code to receive that number and print it on the Serial Monitor. The two Unos are connected only with one wire from Tx on the sending unit to Rx on the receive unit. No shared ground (they will be 50 feet apart eventually, so we didn't assume we had to connect them). So here's what is happening: we send only the number 170 across the wire, and on the receive Serial Monitor screen it shows a 170 very infrequently, but for the most part shows a bunch of random numbers from 1 to maybe 150 or slightly higher. So for example you might get these numbers on the Serial Monitor in the course of a half second: 12 35 101 87 45 170 72 41 29 112
The code I've seen in examples doesn't all have delays, and I haven't seen anything telling me we have to have shared ground, but inserting a wire from GND on one board to GND on the other didn't have an effect. I'll list the Send code first, and then the Receive code. Any help would be greatly appreciated.
Send Code:
int SerialTest = 170;
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.print("I am sending this number: ");
Serial.println(SerialTest);
Serial.write(SerialTest);
delay(5);
}
Receive Code:
int SerialReceive = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.print("My receive variable has this value: ");
Serial.println(SerialReceive);
if (Serial.available() > 0) {
SerialReceive = Serial.read();
}
delay(5);
}