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.
Revision 4:adcf96bb4a51, committed 2020-11-12
- 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;