DFRobot Leonardo with Xbee R3 Manuel - Sayfa 2
Anakart DFRobot Leonardo with Xbee R3 için çevrimiçi göz atın veya pdf Manuel indirin. DFRobot Leonardo with Xbee R3 3 sayfaları.
24/1/2017
Xbee Tutorial
DFRobot Leonardo with Xbee R3 has a Xbee socket.It uses Serial1 to communicate with Leonardo.
Sample Code
// # Description:
// It is just used to test Leonardo module
// Write by Grey
// Input "p" once time the led will be turn on;twice to turn off.
// It is controled by Serial1 Xbee side only. but you can check the status from serial port.
int ledPin=13;
int val;
int count=0;
void setup()
{
pinMode(ledPin,OUTPUT);
Serial.begin(9600);
Serial1.begin(115200); // Xbee Serial1 port baud rate should be set the same to the xbee baud rate
}
void loop()
{
val=Serial1.read(); // read xbee Serial1 data
if(‐1!=val) // "‐1" means no data
{
if('p'==val){
if(count==0)count=1;
else if(count==1)count=0;
}
if(count==0){
digitalWrite(ledPin,HIGH); // Turn on
Serial.println("LED ON"); // you can check the status from serial port.
Serial1.println("LED ON"); //you can check the status from serial1 port(xbee).
}
else if(count==1)
{
digitalWrite(ledPin,LOW); // Turn off
Serial.println("LED OFF"); //you can check the status from serial port.
Serial1.println("LED OFF"); //you can check the status from serial1 port(xbee).
}
}
}
Connection diagram
https://www.dfrobot.com/wiki/index.php/DFRobot_Leonardo_with_Xbee_R3(SKU:DFR0221)
DFRobot Leonardo with Xbee R3(SKU:DFR0221) Robot Wiki
(/wiki/index.php/File:Wp_leonardo.jpg)
DFRduino Leonardo With Xbee
2/3