IR-Distance (Analog Value) Sensor 2$





Introduction: IR-Distance (Analog Value) Sensor 2$

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 :-


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

int ledpin = 9 ;

void setup() {


lcd.begin(16, 2);


void loop() {

int sensorValue = analogRead(A5);

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

if (sensorValue > 60){

lcd.print("Motion Detected");





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






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...



    • Water Contest

      Water Contest
    • Clocks Contest

      Clocks Contest
    • Creative Misuse Contest

      Creative Misuse Contest

    6 Discussions

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

    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

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

    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.!

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