![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
This consists of the transmitter code to send characters wirelessly using the Zigbee protocol.
Fork of Xbee_transmitter by
main.cpp@0:e7abcef0b57f, 2012-12-07 (annotated)
- Committer:
- abarve9
- Date:
- Fri Dec 07 07:29:32 2012 +0000
- Revision:
- 0:e7abcef0b57f
- Child:
- 1:004033e7a7c7
The transmitter code used to transmit characters wirelessly using Zigbee protocol.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
abarve9 | 0:e7abcef0b57f | 1 | /// SENDER ZIGBEE |
abarve9 | 0:e7abcef0b57f | 2 | |
abarve9 | 0:e7abcef0b57f | 3 | #include "mbed.h" |
abarve9 | 0:e7abcef0b57f | 4 | #include "iostream" |
abarve9 | 0:e7abcef0b57f | 5 | #include "stdio.h" |
abarve9 | 0:e7abcef0b57f | 6 | #include "stdlib.h" |
abarve9 | 0:e7abcef0b57f | 7 | using namespace std; |
abarve9 | 0:e7abcef0b57f | 8 | |
abarve9 | 0:e7abcef0b57f | 9 | Serial pc(USBTX, USBRX); |
abarve9 | 0:e7abcef0b57f | 10 | |
abarve9 | 0:e7abcef0b57f | 11 | Serial xbee1(p9,p10); |
abarve9 | 0:e7abcef0b57f | 12 | DigitalOut rst1(p11); //Digital reset for the XBee, 200ns for reset |
abarve9 | 0:e7abcef0b57f | 13 | |
abarve9 | 0:e7abcef0b57f | 14 | |
abarve9 | 0:e7abcef0b57f | 15 | DigitalOut myled(LED1);//Create variable for Led 3 on the mbed |
abarve9 | 0:e7abcef0b57f | 16 | |
abarve9 | 0:e7abcef0b57f | 17 | int main() |
abarve9 | 0:e7abcef0b57f | 18 | { |
abarve9 | 0:e7abcef0b57f | 19 | int character; |
abarve9 | 0:e7abcef0b57f | 20 | char buffer[20]; |
abarve9 | 0:e7abcef0b57f | 21 | rst1 = 0; //Set reset pin to 0 |
abarve9 | 0:e7abcef0b57f | 22 | myled = 0;//Set LED3 to 0 |
abarve9 | 0:e7abcef0b57f | 23 | wait_ms(1);//Wait at least one millisecond |
abarve9 | 0:e7abcef0b57f | 24 | rst1 = 1;//Set reset pin to 1 |
abarve9 | 0:e7abcef0b57f | 25 | wait_ms(1);//Wait another millisecond |
abarve9 | 0:e7abcef0b57f | 26 | |
abarve9 | 0:e7abcef0b57f | 27 | |
abarve9 | 0:e7abcef0b57f | 28 | while (1) |
abarve9 | 0:e7abcef0b57f | 29 | |
abarve9 | 0:e7abcef0b57f | 30 | { |
abarve9 | 0:e7abcef0b57f | 31 | if(pc.readable()) { |
abarve9 | 0:e7abcef0b57f | 32 | //pc.gets(buffer,10); |
abarve9 | 0:e7abcef0b57f | 33 | //xbee1.putc(buffer); //XBee write whatever the PC is sending |
abarve9 | 0:e7abcef0b57f | 34 | myled = !myled; |
abarve9 | 0:e7abcef0b57f | 35 | character = pc.getc(); |
abarve9 | 0:e7abcef0b57f | 36 | xbee1.putc(character); |
abarve9 | 0:e7abcef0b57f | 37 | pc.putc(character); |
abarve9 | 0:e7abcef0b57f | 38 | |
abarve9 | 0:e7abcef0b57f | 39 | } |
abarve9 | 0:e7abcef0b57f | 40 | |
abarve9 | 0:e7abcef0b57f | 41 | //pc.printf("I got %s on sending side \n", buffer); |
abarve9 | 0:e7abcef0b57f | 42 | wait(.1); |
abarve9 | 0:e7abcef0b57f | 43 | } |
abarve9 | 0:e7abcef0b57f | 44 | } |