n/a
Dependencies: SoftwareSerial mbed
Fork of XBeeTest by
Diff: main.cpp
- Revision:
- 2:3b1482a11290
- Parent:
- 1:69c55857d969
--- a/main.cpp Fri Nov 13 11:11:39 2015 +0000 +++ b/main.cpp Tue Dec 08 11:11:41 2015 +0000 @@ -1,38 +1,27 @@ -/** - * XBee Example Test - * A test application that demonstrates the ability - * of transmitting serial data via an XBee module with - * an mbed microprocesor. - * By: Vlad Cazan - * Date: Tuesday, September 29th 2009 - */ +#include "mbed.h" +#include "SoftwareSerial.h" -#include "mbed.h" - -Serial xbee1(D1, D0); //Creates a variable for serial comunication through pin 9 and 10 - -//DigitalOut rst1(p11); //Digital reset for the XBee, 200ns for reset - -DigitalOut myled(LED1);//Create variable for Led 3 on the mbed -//DigitalOut myled2(LED4);//Create variable for Led 4 on the mbed - -Serial pc(USBTX, USBRX);//Opens up serial communication through the USB port via the computer +SoftwareSerial xbee1(D3, D2); +DigitalOut myled(LED1); +Serial pc(USBTX, USBRX); int main() { -// rst1 = 0; //Set reset pin to 0 - myled = 0;//Set LED3 to 0 -// myled2= 0;//Set LED4 to 0 -// wait_ms(1);//Wait at least one millisecond -// rst1 = 1;//Set reset pin to 1 -// wait_ms(1);//Wait another millisecond + char buffer[256]; + char *p; + + xbee1.baud(9600); + int count = 1; + myled = 0; - while (1) {//Neverending Loop - //if (pc.readable()) {//Checking for serial comminication - myled = 0; //Turn Led 3 Off - xbee1.putc('A'); //XBee write whatever the PC is sending - //xbee1.putc(pc.getc()); //XBee write whatever the PC is sending + while (1) { + sprintf(buffer, "%d: (yokota) hello.\r\n", count++); + pc.puts(buffer); //for debugging: print to pc + p = buffer; + while (*p) { + xbee1.putc(*p++); + wait_ms(2); //required for stable communication + } wait_ms(1000); - myled = 1; //Turn Led 3 on for succcessfull communication - //} + myled = 1 - myled; } } \ No newline at end of file