Objective
This experiment demonstrates the use of an infrared sensor to detect objects in proximity, useful in robotics and automation systems.
Required Components
- Infrared Proximity Sensor
- Arduino Board (e.g., Arduino Uno)
- Jumper wires
- Breadboard
- Arduino IDE (for programming)
Working Principle
The infrared sensor detects objects by emitting infrared light and measuring the reflection. If the light is reflected, the sensor detects the object’s proximity.
Circuit Diagram
Connect the sensor as follows:
- Connect the VCC pin of the sensor to the 5V pin on the Arduino.
- Connect the GND pin of the sensor to the GND pin on the Arduino.
- Connect the signal pin of the sensor to digital pin 2 on the Arduino.
Arduino Code
/*
* Infrared Proximity Detection
* This code detects an object within the range of the infrared proximity sensor.
*/
const int irSensorPin = 2; // Infrared sensor connected to digital pin 2
int sensorState = 0;
void setup() {
Serial.begin(9600); // Initialize serial communication
pinMode(irSensorPin, INPUT); // Set the IR sensor pin as input
}
void loop() {
// Read the infrared sensor
sensorState = digitalRead(irSensorPin);
// If an object is detected
if (sensorState == HIGH) {
Serial.println("Object Detected!");
} else {
Serial.println("No Object.");
}
delay(500); // Wait for 0.5 seconds
}
Results
The serial monitor will display "Object Detected!" when the infrared sensor detects an object and "No Object" when no object is in range.
Applications
- Obstacle detection in robots
- Touchless sensing systems
- Object tracking systems
Conclusion
The infrared proximity sensor is a practical component for detecting objects, with applications in robotics, automation, and security systems.