AdjustableInfraredSensorSwitch(SKU:SEN0019)
Contents
1 Introduction
2 Specification
3 Tutorial
3.1 Connection Diagram
3.2 Sample Code
3.3 Result
4 Trouble shooting
Introduction
The DFRobot Adjustable Infrared Sensor Switch is a set of transmitter and receiver in one of the
photoelectric switch sensor. The detection distance can be adjusted according to the demand. The
DFRobot Adjustable Infrared Sensor Switch 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 occasions. The switching signal output differs in accordance to the obstacles. 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
Adjustable detection range: 3cm - 80cm
Pin description:
Red - 5V
Green - GND
Yellow - Digital output
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.
=
Troubleshooting
Q 1. We have to use manual, because describes explanation is too simple?
A: This is a photoelectric switch, only three lines, power, ground and output, so have not too
complicated presentation.
Q 2. Why Connect the power, light has been lit?
A: To ensure stable power supply is 5V ± 2%, followed by the output of the probe is not connected to
the microcontroller output port.
Q 3. Why connect infrared switch power, light has been lit?
A: .Please
1. Check the power supply has not reversed, in a word, the infrared output to supply positive;
2. check the probe is in the direction of the detection range that is no obstacle, the best against the
open direction.
Q 4. If need the pull-up resistor, how much should be?
A: About 10K.
Any question and more cool ideas to share, please visit DFRobot Forum
Powered By DFRobot © 2008-2017