Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // basic xbee example
00002 // - take chars from the terminal, push them out xbee1
00003 // - listen on xbee2, and print value + 1 to terminal
00004 
00005 #include "mbed.h"
00006 
00007 Serial xbee1(p9, p10);
00008 DigitalOut rst1(p11);
00009 
00010 Serial xbee2(p13, p14);
00011 DigitalOut rst2(p15);
00012 
00013 Serial pc(USBTX, USBRX);
00014 
00015 int main() {
00016 
00017     // reset the xbees (at least 200ns)
00018     rst1 = 0;
00019     rst2 = 0;
00020     wait_ms(1); 
00021     rst1 = 1;
00022     rst2 = 1;
00023     wait_ms(1); 
00024  
00025     while(1) {
00026         if(pc.readable()) {
00027             xbee1.putc(pc.getc());
00028         }
00029         if(xbee2.readable()) {
00030             pc.putc(xbee2.getc() + 1);
00031         }
00032     }
00033 }