Ir Proximity Sensor
Ir Proximity Sensor
Introduction
Specification
● Power supply: 5V
● Working Current: <100mA
● Recommended Operating Distance: 10~80cm
● Minimum Operating Distance: 3cm
(when the detected surface is non-reflective black plane)
● Maximum Operating Distance: 90cm
(when the detected surface is flat reflective white plane)
● Pin description:
○ Brown - 5V
○ Blue - GND
○ Black- Signal
● Digital output:
○ "0" - found barrier (~0V)
○ "1" - no barrier (~4V)
● Dimension: 45x18mm
Tutorial
Connection Diagram
Sample Code
const int InfraredSensorPin = 4;//Connect the signal pin to the digital pin 4
const int LedDisp = 13;
void setup()
{
Serial.begin(57600);
Serial.println("Start!");
pinMode(InfraredSensorPin,INPUT);
pinMode(LedDisp,OUTPUT);
digitalWrite(LedDisp,LOW);
}
void loop()
{
if(digitalRead(InfraredSensorPin) == LOW) digitalWrite(LedDisp,HIGH);
else digitalWrite(LedDisp,LOW);
Serial.print("Infrared Switch Status:");
Serial.println(digitalRead(InfraredSensorPin),BIN);
delay(50);
}
Copy
Result
Cover the sensor head with your hand, the LED(Pin13) on board will light up, hold it
toward an open area, the LED will be off. Open Arduino IDE serial monitor, you can
also get the Infrared sensor status.
FAQ
A1 This is a photoelectric switch and only have three lines which are :
power, ground and output, Therefore its presentation is not too
complicated.
Q2 Why does the light not turn on when I connect the power?
Q3 Why does the light turns on when I connect the infrared switch power?
A3 Please first check the power supply, make sure the lines are not
reversed, in a word, the infrared output to supply should be positive;
Second, check the probe, make sure it pointed in the correct deriction
with no obstacle in its path.
A4 About 10K.
Any question and more cool ideas to share, please visit DFRobot Forum