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