8 float value = float(reading);
9 float value2 = value * value;
11 return 2583.711122992086f
12 - 20.19789785547f * value + 0.071746539329f * value2
13 - 0.000115854182f * value2 * value + 0.000000068590f * value2 * value2;
22 float read = analogRead(
pin);
A class for interfacing with the SHARP GP2Y distance sensor.
float Filter(float value)
Filters the input value using the running average.
float distance
Current distance measurement.
RunningAverageFilter< 25 > rAF
Running average filter for smoothing sensor readings.
float Update()
Updates the distance measurement by reading the sensor.
uint8_t pin
Analog pin connected to the sensor.
float GetDistance()
Retrieves the current distance measurement.
float ReadingToDistance(uint8_t reading)
Converts a raw sensor reading to a distance value.
SHARPGP2Y(uint8_t pin)
Constructs a SHARPGP2Y instance with the specified pin.