4-CH IR Line Sensor Module Documentation
The 4-CH IR Line Sensor Module is a highly sensitive and compact infrared sensor designed for line detection and tracking applications. This module features four individual infrared sensors, each with its own transmitter and receiver, allowing for accurate detection of objects or lines. The module provides a digital output signal, making it easy to interface with microcontrollers, robots, and other IoT devices.
Four individual infrared sensors for accurate line detection
Digital output signal (0V or 5V) for easy interfacing with microcontrollers
High sensitivity and accuracy for reliable line tracking
Compact design for easy integration into robotics, automation, and IoT projects
Operating voltage: 5V
Communication protocol: Digital output
The 4-CH IR Line Sensor Module has the following pinout:
| Pin | Description |
| --- | --- |
| VCC | Power supply (5V) |
| GND | Ground |
| D0 | Digital output for channel 0 |
| D1 | Digital output for channel 1 |
| D2 | Digital output for channel 2 |
| D3 | Digital output for channel 3 |
### Example 1: Basic Line Detection with Arduino
In this example, we'll use the 4-CH IR Line Sensor Module with an Arduino board to detect a black line on a white surface.
```c++
const int sensorPins[] = {2, 3, 4, 5}; // Digital pins for sensor outputs
void setup() {
Serial.begin(9600);
for (int i = 0; i < 4; i++) {
pinMode(sensorPins[i], INPUT);
}
}
void loop() {
for (int i = 0; i < 4; i++) {
int sensorState = digitalRead(sensorPins[i]);
if (sensorState == LOW) {
Serial.print("Line detected on channel ");
Serial.println(i);
}
}
delay(50);
}
```
### Example 2: Line Follower Robot with Raspberry Pi (using Python)
In this example, we'll use the 4-CH IR Line Sensor Module with a Raspberry Pi to create a line follower robot.
```python
import RPi.GPIO as GPIO
import time
sensorPins = [17, 23, 24, 25] # GPIO pins for sensor outputs
for pin in sensorPins:
GPIO.setup(pin, GPIO.IN)
while True:
sensorStates = [GPIO.input(pin) for pin in sensorPins]
if all(sensorStates): # If all sensors detect the line
print("Moving forward")
# Control motor to move forward
elif any(sensorStates): # If any sensor detects the line
print("Adjusting direction")
# Control motor to adjust direction
else:
print("Lost the line")
# Control motor to stop or reverse
time.sleep(0.05)
```
Note: These code examples are for illustrative purposes only and may require modification to suit your specific application. Ensure proper calibration and testing of the sensor module before deploying it in your project.