Aditya Barve / Mbed 2 deprecated Xbee_transmitter

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /// SENDER ZIGBEE
00002 
00003 #include "mbed.h"
00004 #include "iostream"
00005 #include "stdio.h"
00006 #include "stdlib.h"
00007 using namespace std;
00008 
00009 Serial pc(USBTX, USBRX);
00010 
00011 Serial xbee1(p9,p10);
00012 DigitalOut rst1(p11); //Digital reset for the XBee, 200ns for reset
00013 
00014 
00015 DigitalOut myled(LED1);//Create variable for Led 3 on the mbed
00016 
00017 int main()
00018 {
00019     int character;
00020     char buffer[20];
00021     rst1 = 0; //Set reset pin to 0
00022     myled = 0;//Set LED3 to 0
00023     wait_ms(1);//Wait at least one millisecond
00024     rst1 = 1;//Set reset pin to 1
00025     wait_ms(1);//Wait another millisecond
00026 
00027 
00028     while (1)
00029 
00030     {
00031         if(pc.readable()) {
00032             //pc.gets(buffer,10);
00033             //xbee1.putc(buffer); //XBee write whatever the PC is sending
00034             myled = !myled;
00035             character = pc.getc();
00036             xbee1.putc(character);
00037             pc.putc(character);
00038 
00039         }
00040 
00041         //pc.printf("I got %s on sending side \n", buffer);
00042         wait(.1);
00043     }
00044 }