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
Fork of AVC_Robot_Controled_Navigation by
my_libraries/ultrasonic.cpp
- Committer:
- gerardo_carmona
- Date:
- 2014-10-17
- Revision:
- 3:bd16e43ad7be
- Parent:
- 2:94059cb643be
- Child:
- 4:c60636c95b80
File content as of revision 3:bd16e43ad7be:
// ----- Libraries ------------------------------------------------------------------ #include "mbed.h" #include "ultrasonic.h" // ----- Constants ------------------------------------------------------------------ // ----- I/O Pins ------------------------------------------------------------------- AnalogIn ultra_lef(A2); AnalogIn ultra_rig(A3); // ----- Others --------------------------------------------------------------------- // ----- Variables ------------------------------------------------------------------ double read_sensor, cm; // ----- Functions ------------------------------------------------------------------ float ultrasonicos(int sensor){ 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; return cm; }