2.30 IR Obstacle Avoidance Sensor

Overview

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.

Components Required

../_images/Part_two_30.png

Fritzing Circuit

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.

../_images/image231.png

Schematic Diagram

../_images/image232.png

Code

Note

  • You can open the file 2.30_irSensorModule.ino under the path of sunfounder_vincent_kit_for_arduino\code\2.30_irSensorModule directly.

  • Or copy this code into Arduino IDE.

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.

Phenomenon Picture

../_images/image233.jpeg