![](/media/cache/profiles/25a76ba89c58a499eadfd4cb8ecf8af5.jpg.50x50_q85.jpg)
send analog info from MaxBotix range finder with xbee. Download onto the End Device with the sensor.
Dependencies: C12832_lcd mbed xbee_lib
Revision 0:8aac1b3be648, committed 2015-02-16
- Comitter:
- dannellyz
- Date:
- Mon Feb 16 02:27:53 2015 +0000
- Commit message:
- round1;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/C12832_lcd.lib Mon Feb 16 02:27:53 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/dreschpe/code/C12832_lcd/#8f86576007d6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Feb 16 02:27:53 2015 +0000 @@ -0,0 +1,35 @@ +#include "mbed.h" +#include "C12832_lcd.h" +#include "xbee.h" +C12832_LCD lcd; +AnalogIn ain(p17); +Serial pc(USBTX, USBRX); // tx, rx +xbee xbee1(p9,p10,p30); //Initalise xbee_lib + +int main() { + float adc, volts, inches; + int feet, in,out; + char send_data[2]; //Xbee buffer size is 202 bytes + + lcd.cls(); + lcd.locate(0,2); + + while (1){ + adc = ain.read(); // read analog as a float + volts = adc * 3.3; // convert to volts + inches = (volts / 0.0064) ; // 3.3V supply: ~6.4mV per inch + feet = (int) inches / 12; // inches to feet (trunc) + in = (int) inches % 12; // remainder: in(ches) + out = (int) inches; + pc.printf("adc:%8.2f %8.2fV in:%8.2f %d'%d\"\n", + adc, volts, inches, feet, in); + + lcd.printf("%.2fV in: %.2f send: %d\n", + volts, inches,out); + if(out < 10){sprintf (send_data, "0%d", out);} + else{sprintf (send_data, "%d", out);} + xbee1.SendData(send_data); //Send data to XBee + wait(0.05); // ~20Hz update rate ; note we aren't + // truly synchronized ... + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Feb 16 02:27:53 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xbee_lib.lib Mon Feb 16 02:27:53 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/tristanjph/code/xbee_lib/#ede20c047d8b