Receive data from maxbotix rangefinder with xbee. Illuminate BUS leds if something is within 2 feet.
Dependencies: C12832_lcd mbed xbee_lib
Diff: main.cpp
- Revision:
- 0:0ae2b2f49936
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Feb 16 02:28:48 2015 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" +#include "xbee.h" +#include "C12832_lcd.h" // Include for LCD code +#include <stdio.h> +xbee xbee1(p9,p10,p30); //Initalise xbee_lib +Serial pc(USBTX, USBRX); //Initalise PC serial comms +C12832_LCD lcd; +BusOut leds(LED1,LED2,LED3,LED4); +int main() { + char read_data[2]; //Xbee buffer size is 202 bytes + int out = 0; + while(1) { + xbee1.RecieveData(read_data,2); //Read data from the XBee + out = atoi(read_data); + //If something is closer than 2ft illumiate BUS leds + if(out < 24){ + leds = 0xFFFF; + } + else{leds = 0;} + pc.printf("Range: %s \r",read_data); + lcd.cls(); + lcd.locate(0,2); + lcd.printf("Range: %s \r",read_data); + wait(.1); + } +}