AVR Competition / Mbed 2 deprecated AVC_Robot_Controled_Navigation

Dependencies:   FXOS8700CQ SDFileSystem mbed

Revision:
2:94059cb643be
Child:
3:bd16e43ad7be
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/my_libraries/ultrasonic.cpp	Thu Oct 16 17:30:52 2014 +0000
@@ -0,0 +1,29 @@
+// ----- Libraries ------------------------------------------------------------------
+#include "mbed.h"
+#include "ultrasonic.h"
+
+// ----- Constants ------------------------------------------------------------------
+#define ULTRA_R 1
+#define ULTRA_L 2
+
+// ----- 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;
+}
\ No newline at end of file