IR-Distance (Analog Value) Sensor 2$

5,262

68

6

This Homemade IR Distance Sensor can easily sense distance betwwn 55 cm to 0.5 cm and display it on a 16X2 LCD

it does not require any costly sensors or drivers.....

all it uses is an IR Pair and a few resistors ............

the cost of the finished sensor is under 2$ !!!! Happy Constructing

Step 1: Getting Started

You will require these materials for the build :-

-- IR LED Pair(Transmitter and Reciever)

-- 16X2 LCD

-- 10 K Resistor

-- LED (Normal)

-- Breadboard

-- Jumper Wires

-- Arduino (or other microcontroller) ...

Step 2: The Circuit !!!

just follow the fritzing diagram :-

also add the lcd from pins 7 to 2

like this wiring :-

* LCD RS pin to digital pin 7
* LCD Enable pin to digital pin 6

* LCD D4 pin to digital pin 5

* LCD D5 pin to digital pin 4

* LCD D6 pin to digital pin 3

* LCD D7 pin to digital pin 2

* LCD R/W pin to ground

* 10K resistor: ends to +5V and ground

* wiper to LCD VO pin (pin 3)

Step 3: Code It !!!!

the code is :-

[CODE/]

#include
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

int ledpin = 9 ;

void setup() {

Serial.begin(9600);

lcd.begin(16, 2);

}

void loop() {

int sensorValue = analogRead(A5);

sensorValue = map (sensorValue,3,20,0,1000);

if (sensorValue > 60){

lcd.print("Motion Detected");

lcd.setCursor(0,1);

lcd.print(sensorValue);

}

Serial.println(sensorValue);

sensorValue = map (sensorValue,0,1000,0,255);

analogWrite(ledpin,sensorValue);

delay(50);

lcd.clear();

}

[/CODE]

Step 4: Caliberating the Sensor !!!!!

when there is no object in front of the sensor then the value that is displayed on the lcd is the minimum value

just place it into the

minValue of the given code:-

in my case it was 58 so i decided to go onto 60..

put the value in the map function...

Share

    Recommendations

    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • Plastics Contest

      Plastics Contest
    • Optics Contest

      Optics Contest

    6 Discussions

    0
    None
    guptakunal224

    Question 9 months ago on Step 2

    Why is there no connection to power (Vcc) for the receiver (phototransistor) in the circuit?

    0
    None
    johnyradio

    3 years ago on Introduction

    hi, is the arduino required? What signal is going into the Arduino from the detector? How does it change as distance changes? thx

    1 reply
    0
    None
    HarshVjohnyradio

    Reply 2 years ago

    Sorry . I am too late for replying . You might wanna google it . I cant explain it briefly...its inveraly proportional

    0
    None

    Yeah, It is so protective, that it can even be used upto 64 volts (DC) (I've tested it..!)...and I've used arduino to sense the current itself.....!it's amazing.!

    0
    None
    HarshVHarshV

    Reply 4 years ago

    Sorry,,, the above comment is for opto isolator.