This consists of the transmitter code to send characters wirelessly using the Zigbee protocol.

Dependencies:   mbed

main.cpp

Committer:
abarve9
Date:
2012-12-07
Revision:
0:e7abcef0b57f

File content as of revision 0:e7abcef0b57f:

/// 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);
    }
}