Smartcar Shield
Loading...
Searching...
No Matches
Public Member Functions | List of all members
GP2Y0A02 Class Reference

Programmatically represents a SHARP GP2Y0A02 infrared sensor. More...

#include <GP2Y0A02.hpp>

Inheritance diagram for GP2Y0A02:
Inheritance graph
Collaboration diagram for GP2Y0A02:
Collaboration graph

Public Member Functions

 GP2Y0A02 (Runtime &runtime, uint8_t pin)
 Constructs a GP2Y0A02 sensor.
 
unsigned int getDistance () override
 Gets the distance measured by the sensor in centimeters.
 
- 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.
 
- Public Member Functions inherited from DistanceSensor
virtual ~DistanceSensor ()=default
 

Detailed Description

Programmatically represents a SHARP GP2Y0A02 infrared sensor.

It can measure distances between 25 and 120 centimeters.

Definition at line 11 of file GP2Y0A02.hpp.

Constructor & Destructor Documentation

◆ GP2Y0A02()

GP2Y0A02::GP2Y0A02 ( Runtime &  runtime,
uint8_t  pin 
)

Constructs a GP2Y0A02 sensor.

Parameters
runtimeThe runtime environment you want to run the class for
pinThe analog pin receiving sensor signals

Example:

ArduinoRuntime arduinoRuntime,
const unsigned short IR_PIN = A1;
GP2Y0A02 infraredSensor(arduinoRuntime, IR_PIN);
The class to programatically represent the Arduino runtime environment or alternatively calls to the ...
Programmatically represents a SHARP GP2Y0A02 infrared sensor.
Definition GP2Y0A02.hpp:12

Definition at line 9 of file GP2Y0A02.cpp.

Member Function Documentation

◆ getDistance()

unsigned int GP2Y0A02::getDistance ( )
overridevirtual

Gets the distance measured by the sensor in centimeters.

Calling this might trigger a new measurement by the sensor.

Returns
0 if an error has occured, otherwise the measured distance in centimeters

Example:

unsigned int distance = sensor.getDistance();

Implements DistanceSensor.

Definition at line 16 of file GP2Y0A02.cpp.

Here is the call graph for this function:

The documentation for this class was generated from the following files: