1#include "GP2Y0A21_Sensor.h"
4#define MIN_THRESHOLD 1000
6GP2Y0A21_Sensor::GP2Y0A21_Sensor()
13 ir_sensor_pin = pin_num;
14 pinMode(ir_sensor_pin, mode);
20 return analogRead(ir_sensor_pin);
27 analogVal = analogRead(ir_sensor_pin);
28 if (analogVal < MIN_THRESHOLD)
35 return ((
long)1488000 / (analogVal + 16)) - 25;
43 return (
float)distanceMM / 25.4;
int16_t readMM()
Read the distance from the Sharp distance sensor in millimeters.
bool begin(uint8_t pin_num, uint8_t mode=INPUT_PULLDOWN)
Initialize the distance sensor class.
float readIN()
Read the distance from the Sharp distance sensor in inches.
uint16_t read()
Read the value from distance sensor.