The 5-Channel IR (Infrared) Sensor is an electronic device capable of detecting infrared light across five distinct channels. This sensor is commonly used in line-following robots, edge detection, and object sorting based on reflective properties. It is particularly popular in educational robotics and automation projects.
Pin Number | Description |
---|---|
1 | VCC (Power Supply) |
2 | GND (Ground) |
3 | OUT1 (Channel 1) |
4 | OUT2 (Channel 2) |
5 | OUT3 (Channel 3) |
6 | OUT4 (Channel 4) |
7 | OUT5 (Channel 5) |
// Define the sensor output pins
const int sensorPins[5] = {2, 3, 4, 5, 6};
void setup() {
// Initialize each sensor pin as an input
for (int i = 0; i < 5; i++) {
pinMode(sensorPins[i], INPUT);
}
Serial.begin(9600);
}
void loop() {
// Read and print the state of each sensor
for (int i = 0; i < 5; i++) {
int sensorState = digitalRead(sensorPins[i]);
Serial.print("Sensor ");
Serial.print(i + 1);
Serial.print(": ");
Serial.println(sensorState);
}
delay(100); // Short delay before the next reading
}
Remember to always power down your circuit before making any changes to prevent damage to the sensor or other components.