Digital Adjustable Infrared Proximity Sensor for Arduino (0~200 cm) Wiki

SEN0239 Gravity: Digital Adjustable Infrared Proximity Sensor

Introduction

A photoelectric switch is frequently used to detect the presence or absence of a detected object using light. This is an Arduino digital infrared distance sensor with an adjustable detection range from 0cm - 200cm. It only has a size of 75×18mm(2.95×0.71"), but easy to use and assemble.

Infrared photoelectric switch module can be widely used in all sorts of fields such as, mechanical, texitle, light industry etc. When using the Diffuse Reflection Infrared Switch, we have to pay close attention to the working environment of the sensor. Although the sensor can work properly in conditions with high envoronmental illumination, still, please avoid putting the sensor optical aixs right in front of intense light source like sunlight, incandescent lamp and so on.

To ease the difficult of using this sensor, a Gravity Interface is adapted to allow plug & play. The IO expansion shield is the best match for connecting the sensor to your Arduino controller.

The principle of IR photoelectric switch: Light is a kind of electromagnetic ray, similar with radio and X-ray. Its transmission speed can reach up to 300000 Km/s, but light can be absorbed just at its emission instant. Infrared photoelectric switch can be used to detect objects through near-infrared ray or infrared ray that is invisible to human eyes. The main point of IR photoelectric switch is that it can process the variations in the intensity of light:use optical elements to make light beam change in its transmission media; light beam will be reflected by objects; light beam returns instantly after going for a long distance. Photoelectric switch usually includes a light emission head for emitting light to an object to be detected, a light reception head for receiving light from the object, and a main unit for processing the received light from the light reception head.

Specification

Pinout

SEN0239 Gravity: Digital Adjustable Infrared Proximity Sensor Pinout
Label Name Description
Blue D Switch Signal
Isabellinus VCC 3V or 5V
Black GND Ground

Tutorial

Requirements

Connection Diagram

SEN0239 Gravity: Digital Adjustable Infrared Proximity Sensor Connection Diagram

Detection Distance Adjustment

SEN0239 Gravity: Digital Adjustable Infrared Proximity Sensor Detection Distance Adjustment SEN0239 Gravity: Digital Adjustable Infrared Proximity Sensor Detection Distance Adjustment

Sample Code

Serialport band rate 9600bps, display in ASCII.

/*!
   @file SEN0239.ino
   @brief Gravity Digital Adjustable Infrared Proximity Sensor for Arduino
   @n [Get the module here]()
   @n This example is a test sample.
   @n [Connection and Diagram](http://wiki.dfrobot.com.cn/index.php?title=(SKU:SEN0239)%E6%BC%AB%E5%8F%8D%E5%B0%84%E7%BA%A2%E5%A4%96%E7%BA%BF%E5%85%89%E7%94%B5%E5%BC%80%E5%85%B3#.E6.A0.B7.E4.BE.8B.E4.BB.A3.E7.A0.81)

   @copyright  [DFRobot](https://www.dfrobot.com), 2017
   @copyright GNU Lesser General Public License

   @author [lijun](ju.li@dfrobot.com)
   @version  V1.0
   @date  2017-05-15
*/
#define IR 4

void setup() 
{
  Serial.begin(9600);
  Serial.print("switch: ");
  pinMode(IR,INPUT);
}

void loop() 
{
  Serial.println("-------------------------RF-----------------------");
  if(digitalRead(IR) == 1)
    Serial.println("Switch: YES");
  else
    Serial.println("Switch: NO ");
  Serial.println();
}   

Expected Results

SEN0239 Gravity: Digital Adjustable Infrared Proximity Sensor Expected Results

warning_yellow.png Note:

  1. Use constant voltage transformer when using DC power supply, and make sure the power ripple VPP ≤ 10%.
  2. It is not allowed to connect wires with power on. Please do exactly as the connection diagram indicates.

FAQ

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

More Documents