Infrared IR Proximity Sensor Arduino Wiki - DFRobot


This proximity sensor measures reflected infrared(IR) energy to detect the presence of an object within a distance of 10±5mm to 80±20mm. It outputs high/low and has the advantages of strong anti-interference ability, quick response and small size. So this module can be easily embedded in various detection devices like automatic hand washers, smart taps, smart toilets, smart restrooms, and object proximity switches.
In addition, the sensor includes a housing with mounting holes, which allows users to design proper installation for it to ensure waterproofing when applied to scenarios in which it's likely to contact water, such as smart taps and automatic hand washers.



Color Name Description
Red VCC Power +
Black GND Power -
Green OUT Signal Output

Dimension Diagram





Connection Diagram

Sample Code

int led = 13;  // Pin 13 has an LED connected on most Arduino boards.
int sensor = 8;
void setup() {
  pinMode(led, OUTPUT);   // Initialize the digital pin as an output.
  pinMode(sensor, INPUT);
  digitalWrite(led, LOW);

void loop() {
  int val = digitalRead(sensor);
  if (val)
    digitalWrite(led, HIGH);
    digitalWrite(led, LOW);


When the detected object is in the detection range of the sensor, the LED corresponding to pin 13 of the UNO board lights up; when it's outside the detection range, the LED goes out.


For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents

DFshopping_car1.png Get Infrared Proximity Sensor from DFRobot Store or DFRobot Distributor.

Turn to the Top