IR obstacle sensor with TinkerPie
An infrared light and receiver: robot bumpers, object counters.
| Type | Digital sensors |
|---|---|
| Connect to | any accessory pin |
| Gives | true when something is close |
| Simulator | Yes: a control appears under the simulated board |
How it works
The IR obstacle sensor has an infrared LED and an infrared receiver side by side. When something is in front, the invisible light bounces back to the receiver and the output switches on. The blue knob sets the distance.
How to wire it
Signal (DO / OUT / S) to any accessory pin: S1-S4, P10-P13, P43 or P44. Power from 3.3 V where the module allows it.
Code
In blocks: Accessories category in TinkerPie Studio. As code:
// JavaScript
sensors.irObstacle(Pin.S1)
// Arduino C++
sensors::irObstacle(Pin::S1) Good to know
- Range about 2-30 cm, set with the knob.
- Black objects absorb infrared and are hard to see; white ones are easy.
- Bright sunlight can confuse it.
Projects with the IR obstacle sensor
Similar modules
- PIR motion sensor HC-SR501
- Touch sensor TTP223
- Push button module
- Tilt switch SW-520D
- Reed switch (magnet)
- Vibration sensor SW-420
- Hall effect sensor A3144
- Line tracker TCRT5000
Questions
Can I try the IR obstacle sensor without buying one?
Yes. In TinkerPie Studio the simulator shows a control for it under the board, so you can test your program before you build it.
Can the IR obstacle sensor measure distance?
No, it only says yes or no (something is close or not). To measure centimetres, use the HC-SR04 ultrasonic sensor.