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
- Committer:
- yeongsookim
- Date:
- 2020-11-11
- Revision:
- 1:a9251be32d0a
- Parent:
- 0:64fe0ebc42c6
- Child:
- 2:45082fedef80
File content as of revision 1:a9251be32d0a:
#include "DistanceSensor.h" #define MAX_DISTANCE (-1.0) DistanceSensor::DistanceSensor(PinName a): m_analogIn(a) { m_distance = MAX_DISTANCE; } float DistanceSensor::getDistance_cm() { if (m_analog >= 3.0){ distance = 5.0; } else if (m_analog < 3.0 && m_analog >= 2.5){ distance = 10.0; } else if (/* Fill in the blank */){ distance = /* Fill in the blank */; } else{ distance = /* Fill in the blank */; } return distance; }