Justin Park
/
Lab8Part1
Revision 0:9d14f8ea9b2c, committed 2016-03-24
- Comitter:
- jupark
- Date:
- Thu Mar 24 01:11:01 2016 +0000
- Commit message:
- part1;
Changed in this revision
diff -r 000000000000 -r 9d14f8ea9b2c C12832_lcd.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/C12832_lcd.lib Thu Mar 24 01:11:01 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/dreschpe/code/C12832_lcd/#8f86576007d6
diff -r 000000000000 -r 9d14f8ea9b2c main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Mar 24 01:11:01 2016 +0000 @@ -0,0 +1,38 @@ +/********************************************** +MIDN Justin Park and Drew Moore +10 March 2016 +SY202 Lab 8 Part 1 +Description: This function calibrates the distance + measured by an Ultrasonic sensor + +*********************************************/ +#include "mbed.h" +#include "C12832_lcd.h" + +//Initialize the LCD display +C12832_LCD lcd; + +//Read AnalogIn from pin 17 +AnalogIn sensor(p17); // Declare a sensor object with analog input + +//Initialize float variables +float sensorData; // Variable to store the raw output from the sensor +float distance; // Variable to store the actual distance measured by + // the sensor after calibration. + +int main() { + while(1) { + //Put data from the sensor into a variable + sensorData = sensor.read(); + // Turn voltage value into distance using equation from excel sheet + + distance = 399.86 * sensorData - 0.6574; // Use this formula for a 4.7V source. + //Use: distance = 551.68 * sensorData + 0.1376; for a 3.3V source + + //print distance on the LCD in the middle row + lcd.locate(0,10); + //lcd.printf("%f", sensorData); + lcd.printf("%f", distance); + wait(1); // Pause the program every second for readability + } +}
diff -r 000000000000 -r 9d14f8ea9b2c mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Mar 24 01:11:01 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/87f2f5183dfb \ No newline at end of file