4 Channel Infrared Module Features
This module has 4 IR transmitter and receiver pairs that can be used to detect black and white color as well as obstacles. Each channel has digital voltage output. You can adjust the sensor’s sensitivity using the on board potentiometers.
Pinout
You can see pinout of IR module in the image below.
Required Materials
Hardware Components
Software Apps
Interfacing with Arduino
Step 1: Circuit
The following circuit shows how you should connect Arduino to IR module. Connect wires accordingly.
Step 2: Code
Upload the following code to your Arduino.
/*
/*
IR Sensors
modified on 03 Oct 2020
by Mohammad Reza Akbari @ Electropeak
Home
*/
// constants won't change. They're used here to set pin numbers:
const int sensor1 = 2;
int val = 0;
void setup() {
Serial.begin(9600);
pinMode(sensor1, INPUT);
}
void loop() {
val = digitalRead(sensor1);
Serial.println(val);
delay(20);
}
The code output is as follows. When sensor detects an obstacle or a white object, the output is LOW.