An Infrared (IR) Proximity Sensor is an electronic device that detects the presence or absence of an object by measuring the infrared light reflecting off it. This sensor is widely used in various applications such as robotics, automation systems, security devices, and interactive installations. It operates by emitting an infrared signal and then receiving the reflected signal to determine the proximity of an object.
Pin Number | Name | Description |
---|---|---|
1 | VCC | Power supply (3.3V to 5V) |
2 | GND | Ground connection |
3 | OUT | Output signal (Digital or Analog) |
4 | EN | Enable pin (optional, not present on all models) |
// Define the sensor output pin
const int sensorPin = 2;
void setup() {
// Initialize the sensor output pin as an input
pinMode(sensorPin, INPUT);
// Begin serial communication at 9600 baud rate
Serial.begin(9600);
}
void loop() {
// Read the sensor value
int sensorValue = digitalRead(sensorPin);
// Print the sensor value to the serial monitor
Serial.println(sensorValue);
// A short delay before the next reading
delay(100);
}
Q: Can the sensor detect transparent objects? A: It depends on the object's IR reflectivity. Some transparent materials may not reflect IR light well, making detection difficult.
Q: What is the maximum range of the sensor? A: The maximum range varies by model but is typically around 30cm.
Q: Can the sensor be used outdoors? A: While some models may be designed for outdoor use, environmental factors like sunlight can affect the sensor's performance. It's best to consult the manufacturer's specifications.
Remember to consult the specific datasheet for your Infrared Proximity Sensor model for precise information and instructions.