Zac Dannelly
/
serial2Way
2-way comms for mbed appBoard and Xbees
Diff: main.cpp
- Revision:
- 0:bbc1e8143334
- Child:
- 1:2513e17b33db
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Feb 15 04:19:46 2015 +0000 @@ -0,0 +1,33 @@ +//Pins for xbee on appBord found on back +//tx = p9 +//rx = p10 +//status = p29 +//reset = p30 + +//Code to send and recieve serial comms on +//mbed appBoard with xbees +#include "mbed.h" + +//Initialize xbee +Serial xbee(p9, p10); +DigitalOut rst1(p30); + +//Initialize terminal +Serial pc(USBTX, USBRX); + +int main() { + + // reset the xbees (at least 200ns) + rst1 = 0; + wait_ms(1); + rst1 = 1; + wait_ms(1); + while(1) { + if(pc.readable()) { + xbee.putc(pc.getc()); + } + if(xbee.readable()) { + pc.putc(xbee.getc() + ); + } + } +} \ No newline at end of file