Smartcar Shield
|
#include <GP2Y0A21.hpp>
Public Member Functions | |
GP2Y0A21 (Runtime &runtime, uint8_t pin) | |
Constructs a GP2Y0A21 sensor. More... | |
unsigned int | getDistance () override |
Gets the distance measured by the sensor in centimeters. More... | |
Public Member Functions inherited from InfraredAnalogSensor | |
InfraredAnalogSensor (Runtime &runtime) | |
unsigned int | getMedianDistance (uint8_t iterations=smartcarlib::constants::analogInfraredSensor::kDefaultIterations) override |
Gets the median distance from the specified number of measurements. More... | |
Public Member Functions inherited from DistanceSensor | |
virtual | ~DistanceSensor ()=default |
Programmatically represents a SHARP GP2Y0A21 infrared sensor. It can measure distances between 12 and 78 centimeters.
Definition at line 11 of file GP2Y0A21.hpp.
GP2Y0A21::GP2Y0A21 | ( | Runtime & | runtime, |
uint8_t | pin | ||
) |
Constructs a GP2Y0A21 sensor.
runtime | The runtime environment you want to run the class for |
pin | The analog pin receiving sensor signals |
Example:
Definition at line 9 of file GP2Y0A21.cpp.
|
overridevirtual |
Gets the distance measured by the sensor in centimeters.
Calling this might trigger a new measurement by the sensor.
0
if an error has occured, otherwise the measured distance in centimetersExample:
Implements DistanceSensor.
Definition at line 16 of file GP2Y0A21.cpp.