Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

Arduino-based optical proximity sensor using IR LEDs

By Nikhil Agnihotri

Proximity sensors are used to detect something approaching near. These sensors are useful in many applications like collision avoidance, obstacle detection, path following, touchless sensing, motion detection, and object detection. There are different types of proximity sensors like optical, ultrasonic, capacitive, inductive, and magnetic. The capacitive, inductive, and magnetic proximity sensors are used in specific electronic applications. The optical and ultrasonic proximity sensors have much general use and are quite common among electronics. These sensors come in a wide range according to their technology and distance of sensing.

The most simple kind of proximity sensor is the optical one. These proximity sensors are designed using active infrared sensors, consisting of a pair of IR source and an IR detector. The IR source can be either IR LED (Infrared Light Emitting Diode) or IR Laser Diode. The IR LED or IR Laser Diode transmits infrared light. This light is reflected by any object on which it falls. IR photodiodes that operate as IR detectors are placed in the sensor to capture the reflected IR radiations in a predefined range of distance and angle. Closer is the reflecting object; higher is the intensity of infrared radiation reflected, and lower IR photodiode resistance drops. As a result, IR photodiode passes through greater voltage than when there are no incident IR radiation.

Working of active IR sensors

In this project, a proximity sensor built using IR LED and IR photodiode is used. The proximity sensors built using IR LEDs can sense objects at a short range of few centimeters. The sensor is interfaced with Arduino for application demonstration. In this project, we simply fast blink an LED as the sensor detects a near approaching object. The fast blinking of LED in this project indicates the possibility of a collision with the near approaching object. It gives a visual indication to the user to urge her to act quickly, avoiding a collision.

Example of IR proximity sensor

Components required

  1. Arduino UNO x1
  2. IR LED-Photodiode Module x1
  3. LED x1
  4. Resistor 330Ω x1
  5. Breadboard x1
  6. Connecting wires or jumper wires

Circuit connections

The commonly available IR LED-photodiode pair has three terminals – Ground, VCC, and Output. Connect the VCC and ground terminals of the IR module with 5V out and one of the ground channels of Arduino UNO. Connect the output of the sensor module to pin 2 of the Arduino. Connect the anode of a LED at pin 3 of Arduino UNO while connecting its cathode to the ground. Remember to place a current limiting resistor of 330Ω in series with the LED.

Circuit diagram

Circuit diagram of Arduino and IR LED based proximity sensor

Arduino sketch

unsigned int IRpin = 2;
unsigned int Indicatorpin = 3;

void blink_indicator(){
digitalWrite(Indicatorpin, HIGH);
delay(200);
digitalWrite(Indicatorpin, LOW);
delay(200);
}

void setup() {
pinMode(IRpin, INPUT_PULLUP);
pinMode(Indicatorpin, OUTPUT);
}

void loop() {
if(digitalRead(IRpin) == LOW) blink_indicator();
else digitalWrite(Indicatorpin, LOW);
}

How the circuit works

The IR LED is connected in forward bias in the sensor module. As 5V DC powers the module, the IR LED starts emitting IR radiations. An IR photodiode is placed parallel to the IR LED to detect the reflected radiations. The photodiode is connected in a voltage divider network, whose output goes to the inverting input of LM393 comparator IC. The non-inverting input of the same comparator is connected to a pot for adjustment of the reference voltage. The output of the comparator is taken as the output of the module.

Circuit diagram of IR LED LM393 proximity sensor

When the IR detector receives reflected radiations, its resistance drops. As a result, a voltage higher than the reference voltage is applied at the comparator’s inverting input, and the comparator output turns to LOW.

Arduino is programmed to detect digital input from the IR module. As it detects a LOW logical signal from the IR sensor, it starts blinking LED connected at pin 3. When there is a HIGH logical signal from the IR module in the absence of any near approaching object, Arduino keeps the LED connected at pin 3.

How the code works

The Arduino sketch begins with pin assignment to the IR sensor and indicator LED. In the setup() function, the pin connecting the IR sensor is set to digital input, and the pin connecting indicator LED is set as output. A function blink_indicator() is defined to blink the LED at an interval of 200 milliseconds. In the loop() function, if a LOW is detected at the IR pin, blink_indicator() function is called. Otherwise, the LED pin is set to LOW, keeping the LED off.

Result

Circuit of Arduino and IR LED based proximity sensor


Filed Under: Arduino, Electronic Projects

 

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • PS2 Keyboard To Store Text In SD Card Using Arduino Circuit Setup On Breadboard
    How To Use PS2 Keyboard To Store Text In SD Card Using Arduino- (Part 42/49)
  • Wireless Path Tracking System Using Mouse, XBee And Arduino Circuit Setup On Breadboard
    How To Make A Wireless Path Tracking System Using Mouse, XBee And Arduino- (Part 43/49)
  • How to Make a Wireless Keyboard Using Xbee with Arduino- (Part 44/49)
  • Making Phone Call From GSM Module Using Arduino Circuit Setup On Breadboard
    How to Make Phonecall From GSM Module Using Arduino- (Part 45/49)
  • How to Make a Call using Keyboard, GSM Module and Arduino
    How To Make A Call Using Keyboard, GSM Module And Arduino- (Part 46/49)
  • Receiving SMS Using GSM Module With Arduino Prototype
    How to Receive SMS Using GSM Module with Arduino- (Part 47/49)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • Renesas delivers intelligent sensor solutions for IoT applications
  • Microchip Technology releases AVR-IoT Cellular Mini Development Board
  • Qualcomm acquires Cellwize to accelerate 5G adoption and spur infrastructure innovation
  • MediaTek’s chipset offers high-performance option for 5G smartphones
  • Nexperia’s new level translators support legacy and future mobile SIM cards

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • ADS Cascode Power Amplifier Loadpull Problem
  • lna+mixer noise figure problem
  • Thermal pad
  • DC DC converter output voltage rise time
  • building lm2596 dc dc using Arduino uno

RSS Electro-Tech-Online.com Discussions

  • Where is the fuse ?
  • 500+V power supply from 9V battery using ZVS
  • Control Bare LCD With ATmega328p
  • undefined reference header file in proteus
  • Engine compression high voltage ignition voltage?
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering