I have a setup where two XBEES modules are talking to each other, both using XBEE shields, one attached to an UNO ARDUINO and the other a MEGA ARDUINO. One XBEE sends the data and the other receives it and switch on or off a LED. The problem is the receiver one don't work. This is the sender code
int led = 13;
const int bouton = 2; String inputString;
void setup() {
pinMode(led, OUTPUT);
Serial1.begin(9600);
Serial.begin(9600);
digitalWrite(led, LOW);
}
void loop() {
while (Serial.available() ) {
// get the new byte:
delay(3);
char inChar = Serial.read();
// add it to the inputString:
inputString += inChar;
}
if (inputString.length() >0) {
Serial.println(inputString);
Serial1.println(inputString);
inputString="";
}
}
This the receiver one
int led = 13;
String inputString;
void setup() {
// put your setup code here, to run once:
pinMode(led, OUTPUT);
Serial.begin(9600);
}
void loop() {
while (Serial.available() ) {
// get the new byte:
delay(3);
char inChar = Serial.read();
// add it to the inputString:
inputString += inChar;
}
if (inputString.length() >0) {
Serial.println(inputString);
if (inputString == "on"){
digitalWrite(led,HIGH);
Serial.println("LED ON");
}
if (inputString == "off"){
digitalWrite(led,LOW);
Serial.println("LED OFF");
}
inputString="";
}
}
I get on the serial monitor of ARDUINO UNO what i wrote in the serial monitor of ARDUINO MEGA but the LED don't switch on or off :/