Yeongsoo Kim / Mbed 2 deprecated Mecha_Distance_Sensor

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
yeongsookim
Date:
Thu Nov 12 02:06:05 2020 +0000
Parent:
3:511df198e214
Commit message:
given

Changed in this revision

Sensor/DistanceSensor.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Sensor/DistanceSensor.cpp	Thu Nov 12 01:37:38 2020 +0000
+++ b/Sensor/DistanceSensor.cpp	Thu Nov 12 02:06:05 2020 +0000
@@ -9,17 +9,22 @@
 
 float DistanceSensor::getDistance_cm()
 {
-    if (m_analogIn >= 3.0){
+    float scaled_analog = 3.3*m_analogIn;
+    
+    if (scaled_analog >= 3.0){
         m_distance = 5.0;
     }
-    else if (m_analogIn < 3.0 && m_analogIn >= 2.5){
+    else if (scaled_analog < 3.0 && scaled_analog >= 2.5){
         m_distance = 10.0;
     }
     else if (/* Fill in the blank */){
         m_distance = /* Fill in the blank */;
     }
+    else if (/* Fill in the blank */){
+        m_distance = /* Fill in the blank */;
+    }
     else{
-        m_distance = /* Fill in the blank */;
+        m_distance = MAX_DISTANCE;
     }
     
     return m_distance;