n/a
Dependencies: SoftwareSerial mbed
Fork of XBeeTest by
main.cpp@1:69c55857d969, 2015-11-13 (annotated)
- Committer:
- yokotay
- Date:
- Fri Nov 13 11:11:39 2015 +0000
- Revision:
- 1:69c55857d969
- Parent:
- 0:25aca1983704
- Child:
- 2:3b1482a11290
init
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 | |
yokotay | 1:69c55857d969 | 12 | Serial xbee1(D1, D0); //Creates a variable for serial comunication through pin 9 and 10 |
vcazan | 0:25aca1983704 | 13 | |
yokotay | 1:69c55857d969 | 14 | //DigitalOut rst1(p11); //Digital reset for the XBee, 200ns for reset |
vcazan | 0:25aca1983704 | 15 | |
yokotay | 1:69c55857d969 | 16 | DigitalOut myled(LED1);//Create variable for Led 3 on the mbed |
yokotay | 1:69c55857d969 | 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() { |
yokotay | 1:69c55857d969 | 22 | // rst1 = 0; //Set reset pin to 0 |
vcazan | 0:25aca1983704 | 23 | myled = 0;//Set LED3 to 0 |
yokotay | 1:69c55857d969 | 24 | // myled2= 0;//Set LED4 to 0 |
yokotay | 1:69c55857d969 | 25 | // wait_ms(1);//Wait at least one millisecond |
yokotay | 1:69c55857d969 | 26 | // rst1 = 1;//Set reset pin to 1 |
yokotay | 1:69c55857d969 | 27 | // wait_ms(1);//Wait another millisecond |
vcazan | 0:25aca1983704 | 28 | |
vcazan | 0:25aca1983704 | 29 | while (1) {//Neverending Loop |
yokotay | 1:69c55857d969 | 30 | //if (pc.readable()) {//Checking for serial comminication |
vcazan | 0:25aca1983704 | 31 | myled = 0; //Turn Led 3 Off |
yokotay | 1:69c55857d969 | 32 | xbee1.putc('A'); //XBee write whatever the PC is sending |
yokotay | 1:69c55857d969 | 33 | //xbee1.putc(pc.getc()); //XBee write whatever the PC is sending |
yokotay | 1:69c55857d969 | 34 | wait_ms(1000); |
vcazan | 0:25aca1983704 | 35 | myled = 1; //Turn Led 3 on for succcessfull communication |
yokotay | 1:69c55857d969 | 36 | //} |
vcazan | 0:25aca1983704 | 37 | } |
vcazan | 0:25aca1983704 | 38 | } |