This consists of the transmitter code to send characters wirelessly using the Zigbee protocol.
Fork of Xbee_transmitter by
Diff: main.cpp
- Revision:
- 0:e7abcef0b57f
- Child:
- 1:004033e7a7c7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Dec 07 07:29:32 2012 +0000 @@ -0,0 +1,44 @@ +/// SENDER ZIGBEE + +#include "mbed.h" +#include "iostream" +#include "stdio.h" +#include "stdlib.h" +using namespace std; + +Serial pc(USBTX, USBRX); + +Serial xbee1(p9,p10); +DigitalOut rst1(p11); //Digital reset for the XBee, 200ns for reset + + +DigitalOut myled(LED1);//Create variable for Led 3 on the mbed + +int main() +{ + int character; + char buffer[20]; + rst1 = 0; //Set reset pin to 0 + myled = 0;//Set LED3 to 0 + wait_ms(1);//Wait at least one millisecond + rst1 = 1;//Set reset pin to 1 + wait_ms(1);//Wait another millisecond + + + while (1) + + { + if(pc.readable()) { + //pc.gets(buffer,10); + //xbee1.putc(buffer); //XBee write whatever the PC is sending + myled = !myled; + character = pc.getc(); + xbee1.putc(character); + pc.putc(character); + + } + + //pc.printf("I got %s on sending side \n", buffer); + wait(.1); + } +} \ No newline at end of file