[title]Reading out IR distance sensor[/title]
The class “IRDistanceMeasurement” comes in handy to read out the value of an IR distante sensor.
You define a window where where the object is in a stable distance (‘Equilibrium’). If the object leaves this window, an event will be raised (TooClose or TooFar). If the object enters the stable window again, ‘InEquilibrium’ is raised.
The value of the sensor is read out every xx ms. The value then passed through a moving average filter to eliminate glitches around the windows borders.
The sensor I used was: SHARP GP2Y0A21YK0F.
The output of this sensor is not linear, so I defined the window in milliVolts.
All this is connected on pin 5 of the extender module, which is connected to the mainboard through socket 9. Consult the guides to learn more about pins and sockets.
In the attachment you’ll find:
- Datasheet of the IR sensor
- Electrical wire scheme of the sensor to the extender module