Toll-Free Customer Support 24/7

Xbee Aurdino Code

/*
* Project name:
Xbee Development Board with Voltage Regulator and Level Converter Compatible for Arduino
* Copyright
(c) Researchdesignlab.com
* Description:

* Test configuration:
MCU: ATMEGA328
Dev.Board: Arduino uno
Oscillator: 16 MHz
Software: Arduino

*/

const int ledPin = 13; // the number of the LED pin
int Serial_value = 0; // value read from the xbee
void setup()
{
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
Serial.println("Xbee Arduino sheild ");

// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
}

void loop()
{

if (Serial.available()) //check If data is received form xbee
{
Serial_value=Serial.read(); // read the received data form xbee
if(Serial_value=='N'){ //Xbee value is equal to 'N'
digitalWrite(ledPin, HIGH); // turn LED on:
Serial.println("LED on");
}

else if(Serial_value=='F'){ //Xbee value is equal to 'F'
digitalWrite(ledPin, LOW); // turn LED off:
Serial.println("LED off");
}

}
}

Back to top