Plug it and Arduino can sense your presence of object by infrared!
The Infrared Reflectance Sensor Module carries a single infrared LED and phototransistor pair in an inexpensive, tiny module that can be mounted almost anywhere and is great for obstacle detection of robot and home alert system. The optimal sensing distance is within 50cm (20 inches).
Building interactive work is as easy as piling bricks, just plug it to our Arduino Sensor Shield with a buckled cable, and make it looks professional and neat.
The Infrared Reflectance Sensor Module simply gives a digital signal when it detects infrared reflection from a person or object, so the code is exactly as the one we would use for a pushbutton. Please be noted that, when reflection is detected, it gives a “low” value.
int ledPin = 13; // choose pin for the LED int inputPin = 2; // choose input pin (for Infrared sensor) int val = 0; // variable for reading the pin status void setup() { pinMode(ledPin, OUTPUT); // declare LED as output pinMode(inputPin, INPUT); // declare Infrared sensor as input } void loop(){ val = digitalRead(inputPin); // read input value if (val == HIGH) { // check if the input is HIGH digitalWrite(ledPin, LOW); // turn LED OFF } else { digitalWrite(ledPin, HIGH); // turn LED ON } }![]()
![]()
red light at the back to show presence of object

Recent Comments