2.30 IR Obstacle Avoidance Sensor¶
In this lesson, you will learn how to use IR Obstacle Avoidance Sensor. This module is commonly installed on the car and robot to judge the existence of the obstacles ahead. Also it is widely used in hand held device, water faucet and so on.
We can directly connect the pins of IR Obstacle Sensor Module with the pins of Mega 2560 Board. The digital pin 2 is used to read the signal of IR Obstacle Avoidance Sensor Module. We get the VCC of IR Sensor Module connected to 5V, GND to GND, OUT to digital pin 2.
Uploaded the codes to the Mega2560 board, you can see the readings of pins on the serial monitor. When IR Obstacle Avoidance Sensor Module detects there is something covering ahead, there appears 「0」on the serial monitor; otherwise,「1」is displayed. Refer to:ref:ar_digital_read to check the detail code explanation.