chris stevens / Mbed 2 deprecated FRDM_XBee_read

Dependencies:   TextLCD mbed

Fork of XBee_read by Alex Louden

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "TextLCD.h"
00003 
00004 Serial xbee1(PTC4, PTC3);
00005 DigitalOut rst1(PTC0);
00006 
00007 DigitalOut myled(LED1);
00008 DigitalOut myled2(LED2);
00009 
00010 TextLCD lcd(PTC12,PTC13,PTC16,PTC17,PTA16,PTA17); // rs, e, d4-d7
00011 
00012 int main() {
00013     rst1 = 0;   //Set reset pin to 0
00014     myled = 0;
00015     myled2= 0;
00016     wait_ms(1);
00017     rst1 = 1;   //Set reset pin to 1
00018     wait_ms(1);
00019 
00020     lcd.printf("starting");
00021     wait(2);
00022     lcd.cls();
00023 
00024     int a = 0;
00025     int prev = 0;
00026 
00027     while (1) {
00028 
00029         if(xbee1.readable()){
00030             prev = a;
00031             a = xbee1.getc(); //XBee read
00032             
00033             if (a != prev){
00034                 if (a < 10){
00035                     lcd.printf("%d", a);
00036                 }
00037                 if (a == 254 || a == 253){
00038                     lcd.cls();
00039                 }
00040             }
00041         }
00042     }
00043 }