[vc_row][vc_column width=”1/1″][vc_column_text]Xbee is Digi’s zigbee module. By using Xbee modules with pcDuino and Arduino, we can realize two way wireless communication between pcDuino and Arduino. The button on pcDuino’s side is used to control the LED on Arduino side, and vice verse.
[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width=”1/1″][vc_tour][vc_tab title=”Parts List” tab_id=”1394971925-1-33″][vc_column_text]
- 1 x [bigcommerce link=”/pcduino-an-minipc-with-arduino-headers-ubuntu-android-google-tv/” target=”_blank”]pcDuino V1[/bigcommerce]
- 1 x [bigcommerce link=”/arduino-usb-board-uno-r3/” target=”_blank”]Arduino[/bigcommerce]
- 2 x [bigcommerce link=”/xbee-shield/” target=”_blank”]Xbee Shield[/bigcommerce]
- 1 x [bigcommerce link=”/t-board-to-bridge-arduino-shield-to-pcduino-with-level-shifter/” target=”_blank”]T board[/bigcommerce]
- 2 x [bigcommerce link=”/breadboard-clear-self-adhesive/” target=”_blank”]Bread board[/bigcommerce]
- 2 x Xbee module
- 2 x [bigcommerce link=”/button-module-of-linker-kit-for-pcduino-arduino/” target=”_blank”]Button module[/bigcommerce]
- 2 x [bigcommerce link=”/basic-led-transparent-emits-green-light-5mm/” target=”_blank”]LED light[/bigcommerce]
[/vc_column_text][/vc_tab][vc_tab title=”Schematics” tab_id=”1394971925-2-16″][vc_column_text][/vc_column_text][/vc_tab][vc_tab title=”Wiring Diagram” tab_id=”1394975169890-2-7″][vc_column_text]Circuit used to control LED:
Connection:
1. Connecting Xbee module and pcDuino by XBEE shield and T board.
Note: Move the switch to 5V position on the T board.
2. Arduino part
Note: The Baud Rate of xbee should be 9600.[/vc_column_text][/vc_tab][vc_tab title=”Test Code” tab_id=”1394975642533-3-6″][vc_column_text]Code for pcDuino:
#include <core.h> #include "Serial.h" #define led_pin 9 #define button_pin 10 unsigned char flag; void setup() { //Initialize serial and wait for port to open: pinMode(led_pin,OUTPUT); pinMode(button_pin,INPUT); int rate = 9600; Serial.begin(rate); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } } void loop() { if (Serial.available() > 0) { char receive = Serial.read(); if(receive=='a') flag++; if( (flag%2) ) digitalWrite(led_pin,HIGH); //LED off else digitalWrite(led_pin,LOW); //LED on } if(digitalRead(button_pin)==LOW) { delay(10); if(digitalRead(button_pin)==LOW) Serial.print('b'); delay(200); } }
Code for Arduino:
#include <SoftwareSerial.h> #define RxD 11 #define TxD 12 #define led_pin 9 #define button_pin 10 unsigned char flag; SoftwareSerial mySerial(RxD,TxD); void setup() { pinMode(RxD, INPUT); pinMode(TxD, OUTPUT); pinMode(led_pin,OUTPUT); pinMode(button_pin,INPUT); mySerial.begin(9600); // the Bee baud rate } void loop() { if(digitalRead(button_pin)==LOW) { delay(10); if(digitalRead(button_pin)==LOW) mySerial.print('a'); delay(200); } if(mySerial.available()) { char RX = mySerial.read(); if(RX=='b') flag++; if(flag%2) digitalWrite(led_pin,HIGH); else digitalWrite(led_pin,LOW); } }
[/vc_column_text][/vc_tab][vc_tab title=”Test Results” tab_id=”1394975773149-4-8″][vc_column_text]After connection, run the code.
Press the button of pcDuino side, the red LED lighting.
Press the button of Arduino side, the green LED lighting.
Press both buttons
Leave a Reply
You must be logged in to post a comment.