Infrared (IR) Sensor
In this project, you'll learn how to use an infrared (IR) sensor to either detect an object, or to distinguish between a black and a white color object.
The IR sensor can be used by a robot to avoid hitting a wall when it is configured for object detection, or used in a line tracing robot to follow either a black or white line on the floor when it is configured for black/white color detection.
Parts needed:
| ||
1 | In order for the IR sensor to work correctly, you will first need to calibrate it.
First, identify the signal LED that can be turned on and off by turning the potentiometer.
This is the signal LED used in the calibration and detection below.
Calibration for object detection:
| |
2 | Making the connections
| |
3 | Create a new program and type in this program.
The OUT pin from the IR sensor outputs a LOW value when it receives a reflected IR signal, i.e. detected an object (white), and a HIGH value when it is not receiving a reflected IR signal, i.e. no object (black). Both the signal LED on the IR sensor and the built-in led on the Arduino is turned on when it detects an object (white) and off when there is no object (black). The ! symbol inverts the value from HIGH to LOW or from LOW to HIGH |
|