Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FXOS8700CQ SDFileSystem mbed
Diff: my_libraries/ultrasonic.cpp
- Revision:
- 4:c60636c95b80
- Parent:
- 3:bd16e43ad7be
--- a/my_libraries/ultrasonic.cpp Fri Oct 17 06:21:52 2014 +0000
+++ b/my_libraries/ultrasonic.cpp Fri Oct 17 09:08:06 2014 +0000
@@ -17,12 +17,15 @@
// ----- Functions ------------------------------------------------------------------
float ultrasonicos(int sensor){
+ double inch, volts;
if (sensor == ULTRA_R) {
read_sensor = ultra_rig; // read analog as a float
}else if (sensor == ULTRA_L) {
read_sensor = ultra_lef; // read analog as a float
}
// read_sensor * 3300mv / 6.4 mV/in * 2.54 in/cms
- cm = read_sensor * 1309.6875;
+ volts = read_sensor * 3300;
+ inch = volts / 6.4;
+ cm = inch * 2.54;
return cm;
}
\ No newline at end of file