Adjustable Infrared Sensor Switch
Introduction¶
This infrared distance switch features a high-sensitivity photoreflector to perform distance detection function,ranging from 3cm to 80cm. When the infrared light emitted by the emitter gets reflected on a surface that blocked it, the phototransistor can pick up the signal for distance calculation. Also a potentiometer for adjustment is arranged for easy and clear use. It is small, easy to use/assemble, and inexpensive. Useful for robotics, interactive media, industrial assembly line, etc.
 Model: SOD00380S 
Features¶
- Power supply: 5V
 - Current: 100mA
 - Range: 3-80cm adjustable
 - Red: +5V
 - Yellow: Signal
 - Black: GND
 - Wire length: 20cm
 
Usage¶
Hardware¶
Connect this sensor to your Arduino/Crowduino digital pins( D2 for example). When there is an object behind this sensor, the output would be low. ![]()
Programming¶
1.Download the following program to Arduino, Please refer to here
void setup()  {
 Serial.begin(9600);
 pinMode(2,INPUT);
}
void loop()  {
 while(1)  {
   delay(500);
   if(digitalRead(2)==LOW)  {
     Serial.println("object detected.");
   }
   else  {
     Serial.println("no object detected.");
   }
 }
}
2.open the serial monitor , and set the baudrate to 9600, you will see the output changes with the object behind this sensor or not.
 
 ![]()