Test prog for xbee unit on frdm board

Dependencies:   TextLCD mbed

Fork of XBee_read by Alex Louden

Committer:
cstevens
Date:
Wed Apr 10 14:19:46 2013 +0000
Revision:
1:0d6c92c1ed38
Parent:
0:2eaf86314aea
FRDM version of xbee read program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
alex89 0:2eaf86314aea 1 #include "mbed.h"
alex89 0:2eaf86314aea 2 #include "TextLCD.h"
alex89 0:2eaf86314aea 3
cstevens 1:0d6c92c1ed38 4 Serial xbee1(PTC4, PTC3);
cstevens 1:0d6c92c1ed38 5 DigitalOut rst1(PTC0);
alex89 0:2eaf86314aea 6
alex89 0:2eaf86314aea 7 DigitalOut myled(LED1);
alex89 0:2eaf86314aea 8 DigitalOut myled2(LED2);
alex89 0:2eaf86314aea 9
cstevens 1:0d6c92c1ed38 10 TextLCD lcd(PTC12,PTC13,PTC16,PTC17,PTA16,PTA17); // rs, e, d4-d7
alex89 0:2eaf86314aea 11
alex89 0:2eaf86314aea 12 int main() {
alex89 0:2eaf86314aea 13 rst1 = 0; //Set reset pin to 0
alex89 0:2eaf86314aea 14 myled = 0;
alex89 0:2eaf86314aea 15 myled2= 0;
alex89 0:2eaf86314aea 16 wait_ms(1);
alex89 0:2eaf86314aea 17 rst1 = 1; //Set reset pin to 1
alex89 0:2eaf86314aea 18 wait_ms(1);
alex89 0:2eaf86314aea 19
alex89 0:2eaf86314aea 20 lcd.printf("starting");
alex89 0:2eaf86314aea 21 wait(2);
alex89 0:2eaf86314aea 22 lcd.cls();
alex89 0:2eaf86314aea 23
alex89 0:2eaf86314aea 24 int a = 0;
alex89 0:2eaf86314aea 25 int prev = 0;
alex89 0:2eaf86314aea 26
alex89 0:2eaf86314aea 27 while (1) {
alex89 0:2eaf86314aea 28
alex89 0:2eaf86314aea 29 if(xbee1.readable()){
alex89 0:2eaf86314aea 30 prev = a;
alex89 0:2eaf86314aea 31 a = xbee1.getc(); //XBee read
alex89 0:2eaf86314aea 32
alex89 0:2eaf86314aea 33 if (a != prev){
alex89 0:2eaf86314aea 34 if (a < 10){
alex89 0:2eaf86314aea 35 lcd.printf("%d", a);
alex89 0:2eaf86314aea 36 }
alex89 0:2eaf86314aea 37 if (a == 254 || a == 253){
alex89 0:2eaf86314aea 38 lcd.cls();
alex89 0:2eaf86314aea 39 }
alex89 0:2eaf86314aea 40 }
alex89 0:2eaf86314aea 41 }
alex89 0:2eaf86314aea 42 }
alex89 0:2eaf86314aea 43 }