I am using two XBee Pro S2B modules. One (Router) connected to the laptop via a UART cable. The other (Coordinator) connected to an Arduino Mega with the sketch below. All I need it to do is turn a LED on and off and display the status in the IDE serial monitor. I am using Arduino IDE (v1.6.0).
Arduino sketch:
#include <SoftwareSerial.h>
SoftwareSerial xbee (2,3);
int myData = 0;
int ledPin = 13;
void setup()
{
Serial.begin(9600);
xbee.begin(Serial);
pinMode(ledPin, OUTPUT);
}
void loop()
{
if (Serial.available())
{
int myData = Serial.read();
if(myData == '1')
{
digitalWrite(ledPin,HIGH);
Serial.write(myData, DEC);
}
if(myData == '2')
{
digitalWrite(ledPin,LOW);
Serial.write(myData, DEC);
}
}
}
Where did I go wrong?