![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Xbee-Smart-Home-Inside RX Test
Dependencies: Si7021 mbed-rtos JPEGCamera mbed
Fork of Xbee-Smart-Home-Inside by
main.cpp@0:5b1386641010, 2017-04-17 (annotated)
- Committer:
- pkoirala3
- Date:
- Mon Apr 17 12:34:06 2017 +0000
- Revision:
- 0:5b1386641010
- Child:
- 1:e9068d048f58
Xbee Test RX
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pkoirala3 | 0:5b1386641010 | 1 | /** |
pkoirala3 | 0:5b1386641010 | 2 | * XBee Example Test |
pkoirala3 | 0:5b1386641010 | 3 | * A test application that demonstrates the ability |
pkoirala3 | 0:5b1386641010 | 4 | * of transmitting serial data via an XBee module with |
pkoirala3 | 0:5b1386641010 | 5 | * an mbed microprocesor. |
pkoirala3 | 0:5b1386641010 | 6 | * By: Vlad Cazan |
pkoirala3 | 0:5b1386641010 | 7 | * Date: Tuesday, September 29th 2009 |
pkoirala3 | 0:5b1386641010 | 8 | */ |
pkoirala3 | 0:5b1386641010 | 9 | |
pkoirala3 | 0:5b1386641010 | 10 | #include "mbed.h" |
pkoirala3 | 0:5b1386641010 | 11 | |
pkoirala3 | 0:5b1386641010 | 12 | Serial xbee1(p9, p10); //Creates a variable for serial comunication through pin 9 and 10 |
pkoirala3 | 0:5b1386641010 | 13 | |
pkoirala3 | 0:5b1386641010 | 14 | DigitalOut rst1(p8); //Digital reset for the XBee, 200ns for reset |
pkoirala3 | 0:5b1386641010 | 15 | |
pkoirala3 | 0:5b1386641010 | 16 | DigitalOut myled(LED3);//Create variable for Led 3 on the mbed |
pkoirala3 | 0:5b1386641010 | 17 | DigitalOut myled2(LED4);//Create variable for Led 4 on the mbed |
pkoirala3 | 0:5b1386641010 | 18 | |
pkoirala3 | 0:5b1386641010 | 19 | Serial pc(USBTX, USBRX);//Opens up serial communication through the USB port via the computer |
pkoirala3 | 0:5b1386641010 | 20 | |
pkoirala3 | 0:5b1386641010 | 21 | int main() { |
pkoirala3 | 0:5b1386641010 | 22 | rst1 = 0; //Set reset pin to 0 |
pkoirala3 | 0:5b1386641010 | 23 | myled = 0;//Set LED3 to 0 |
pkoirala3 | 0:5b1386641010 | 24 | myled2= 0;//Set LED4 to 0 |
pkoirala3 | 0:5b1386641010 | 25 | wait_ms(1);//Wait at least one millisecond |
pkoirala3 | 0:5b1386641010 | 26 | rst1 = 1;//Set reset pin to 1 |
pkoirala3 | 0:5b1386641010 | 27 | wait_ms(1);//Wait another millisecond |
pkoirala3 | 0:5b1386641010 | 28 | |
pkoirala3 | 0:5b1386641010 | 29 | while (1) {//Neverending Loop |
pkoirala3 | 0:5b1386641010 | 30 | if (pc.readable()) {//Checking for serial communication |
pkoirala3 | 0:5b1386641010 | 31 | myled = 0; //Turn Led 3 Off |
pkoirala3 | 0:5b1386641010 | 32 | if(xbee1.putc(pc.getc()) == EOF){} //XBee write whatever the PC is sending |
pkoirala3 | 0:5b1386641010 | 33 | else {myled = 1;} //Turn Led 3 on for succcessfull communication |
pkoirala3 | 0:5b1386641010 | 34 | } |
pkoirala3 | 0:5b1386641010 | 35 | } |
pkoirala3 | 0:5b1386641010 | 36 | } |