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.
Sensor/DistanceSensor.cpp@2:45082fedef80, 2020-11-12 (annotated)
- Committer:
- yeongsookim
- Date:
- Thu Nov 12 01:22:53 2020 +0000
- Revision:
- 2:45082fedef80
- Parent:
- 1:a9251be32d0a
- Child:
- 3:511df198e214
given
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yeongsookim | 0:64fe0ebc42c6 | 1 | #include "DistanceSensor.h" |
yeongsookim | 0:64fe0ebc42c6 | 2 | |
yeongsookim | 0:64fe0ebc42c6 | 3 | #define MAX_DISTANCE (-1.0) |
yeongsookim | 0:64fe0ebc42c6 | 4 | |
yeongsookim | 0:64fe0ebc42c6 | 5 | DistanceSensor::DistanceSensor(PinName a): m_analogIn(a) |
yeongsookim | 0:64fe0ebc42c6 | 6 | { |
yeongsookim | 0:64fe0ebc42c6 | 7 | m_distance = MAX_DISTANCE; |
yeongsookim | 0:64fe0ebc42c6 | 8 | } |
yeongsookim | 0:64fe0ebc42c6 | 9 | |
yeongsookim | 0:64fe0ebc42c6 | 10 | float DistanceSensor::getDistance_cm() |
yeongsookim | 0:64fe0ebc42c6 | 11 | { |
yeongsookim | 2:45082fedef80 | 12 | float distance = 0.0; |
yeongsookim | 2:45082fedef80 | 13 | |
yeongsookim | 2:45082fedef80 | 14 | if (m_analogIn >= 3.0){ |
yeongsookim | 0:64fe0ebc42c6 | 15 | distance = 5.0; |
yeongsookim | 0:64fe0ebc42c6 | 16 | } |
yeongsookim | 2:45082fedef80 | 17 | else if (m_analogIn < 3.0 && m_analogIn >= 2.5){ |
yeongsookim | 1:a9251be32d0a | 18 | distance = 10.0; |
yeongsookim | 0:64fe0ebc42c6 | 19 | } |
yeongsookim | 0:64fe0ebc42c6 | 20 | else if (/* Fill in the blank */){ |
yeongsookim | 0:64fe0ebc42c6 | 21 | distance = /* Fill in the blank */; |
yeongsookim | 0:64fe0ebc42c6 | 22 | } |
yeongsookim | 0:64fe0ebc42c6 | 23 | else{ |
yeongsookim | 0:64fe0ebc42c6 | 24 | distance = /* Fill in the blank */; |
yeongsookim | 0:64fe0ebc42c6 | 25 | } |
yeongsookim | 0:64fe0ebc42c6 | 26 | |
yeongsookim | 0:64fe0ebc42c6 | 27 | return distance; |
yeongsookim | 0:64fe0ebc42c6 | 28 | } |