Introduction
The DFRobot Digital Adjustable Infrared Proximity Sensor is a set of a transmitter and a receiver in one photoelectric switch sensor. The detection distance can be adjusted according to the users specfic demands. The sensor is small, easy to use, inexpensive, easy to assemble and can be widely used in robot to avoid obstacles, interactive media, industrial assembly line, and many other scenarios. The switching signal output differs in accordance to the obstacles that it detects. It remains high when no obstacles and remains low when there are obstacles. There is also a red led on its back to indicate the sensor status.
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);
}
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
Q&A | Some general Arduino Problems/FAQ/Tips |
---|---|
Q1 | We have to use the manual because the description is too simple? |
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? |
A2 | Ensure stable a power supply of 5V ± 2%, followed by the output of the probe is not connected to the microcontroller output port. |
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. |
Q4 | If I need a pull-up resistor, how much resistance should it have? |
A4 | About 10K. |
Any question and more cool ideas to share, please visit DFRobot Forum