0% found this document useful (0 votes)
458 views5 pages

IR Sensor Distance Measurement with PIC

This document describes a distance measurement device that uses an infrared (IR) sensor and a PIC microcontroller. The device works by attaching an IR sensor to a rotating disc with a hole and counting the number of rotations. Each full rotation is equal to the circumference of the disc, so multiplying the rotation count by the circumference gives the total distance traveled. The device was simulated using Proteus software and MikroC code. Instructions are provided for building the device using common electronic components like an IR sensor, PIC microcontroller, LCD display, and buttons.

Uploaded by

Teo Java
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
458 views5 pages

IR Sensor Distance Measurement with PIC

This document describes a distance measurement device that uses an infrared (IR) sensor and a PIC microcontroller. The device works by attaching an IR sensor to a rotating disc with a hole and counting the number of rotations. Each full rotation is equal to the circumference of the disc, so multiplying the rotation count by the circumference gives the total distance traveled. The device was simulated using Proteus software and MikroC code. Instructions are provided for building the device using common electronic components like an IR sensor, PIC microcontroller, LCD display, and buttons.

Uploaded by

Teo Java
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

12/11/2020 Distance Measurement Device using IR Sensor with PIC Microcontroller

Microcontroller Based Distance Measurement Project

Distance Measurement Device using IR sensor with PIC


microcontroller:
Proteus Simulation Diagram:

Proteus Simulation

Software Required:
1- MikroC PRO for PIC (version 6.6.2 is good enough for this tutorial,  NOTE: latest version will give errors)
2- Proteus ISIS ( v7.8 or Proteus 8)

Hardware Required:
1- PIC16f877a
2- 16x2 LCD
3- 4MHz oscillator
4- 22pf capacitors (2)
5- 10K variable resistor
6- 9 volts battery
7- 7805 voltage regulator
8- IR Sensor
POWERED BY
9- Push Button
https://hassam794.weebly.com/distance-measurement-device-using-ir-sensor-with-pic-microcontroller.html 1/5
12/11/2020 Distance Measurement Device using IR Sensor with PIC Microcontroller

Working:
It is modern distance measurement device using IR Sensor. IR Senor has a Transmitter and Receiver. IR sensor give output as
signal HIGH or LOW. If we place any object in front of IR sensor it give HIGH output signal otherwise signal remains LOW. So are
you wondering how we will use IR Sensor as distance measurement device?? Pretty Cool. Let me explain. We are using a round
disc wheel with a hole on its corner and IR sensor is xed in front of hole as shown in gure below. Now place the disc wheel on
ground and start rotating wheel when disc hole comes in front of IR Sensor after a complete rotation then IR sensor gives a LOW
signal and we increment distance by one unit. After a one complete round of disc wheel our distance will be equal to the
circumference of disc used.

               Circumference = 2 x (pi) x Radius


               Total distance = round count x circumference

Now multiply the round count by circumference and display on LCD. So we can easily measure distance using this device.

Note: To get more accuracy increase the number of holes on disc and use the formula below
 
              Total distance= count x (circumference/number of holes)

This will give more accurate results.

Procedure:
Now make sure you have all this stuff, rst of all create new project in MikroC, choose your Microcontroller i.e PIC18f452 and
set frequency 4MHz (this is basically the frequency of oscillator, in our case we have used 4MHz). If MikroC asks to import
libraries then click OK to import all libraries. Create a new C le for you project and add the C code (comment your email address
for source code) and save your project. Now it’s time to build .HEX le (we need this le for Simulation and Hardware) you can
nd BUILD on the top layer of MikroC simply click on it or just press Ctrl+F9. .HEX le is now saved in your project folder.

For Proteus Simulink open the .DSN simulation le (comment your email address for simulation le). You will see PIC18f452 in
simulation double click on it and add the .HEX le (you generated in MikroC). Now run the Simulation and wow  our distance
measurement device is ready. If you have any question leave a comment.

POWERED
Also want to implementBY
this on hardware??  If Yes, so keep reading. It’s not as hard as you are thinking just connect all wires as in

https://hassam794.weebly.com/distance-measurement-device-using-ir-sensor-with-pic-microcontroller.html 2/5
12/11/2020 Distance Measurement Device using IR Sensor with PIC Microcontroller

simulation. Make sure your wires are not loose otherwise you will face lot of problems. First of all interface LCD to make sure
your circuit is working. If you have problem interfacing LCD please read my article Interfacing 16x2 LCD with PIC16f877a. I have
covered all basic problem regarding LCD interfacing. So when u have working LCD then come to next point IR sensor
interfacing. In Proteus we don’t have useful IR sensor, there is one IRLINK module in Proteus but it is useless in our case so I have
used push button (attached with R1) on Proteus simulation. We can use IR Sensor on Hardware rather than using push button. IR
Sensor has three pins VCC, ground and output as shown in gure below. Attach the output pin of IR sensor at 19th PIN of
microcontroller (with out using resistor) and also interfacing Rest Button (attached with R2) that’s done our project is ready. If
you have any question leave a comment.

IR Sensor

Author: Engr. Hassam Bin Hassan

10 comments
Leave a message...

Sir can you please send the schematic diagram and source code at: [email protected]

Armstrong Tawanda · 5 months ago · Reply

please send me the source code on my email


[email protected]
thank you.
omar darwazeh · a year ago · Reply

can you send me me the source code [email protected]

Renin · a year ago · Reply

hi can you pllz send me schematic diagram with code for with project

[email protected]
brandes · 2 years ago · Reply

hi [email protected]

andres · 2 years ago · Reply

POWERED BY
hi [email protected] tanks!

https://hassam794.weebly.com/distance-measurement-device-using-ir-sensor-with-pic-microcontroller.html 3/5
12/11/2020 Distance Measurement Device using IR Sensor with PIC Microcontroller

andres · 2 years ago · Reply

hi sir i want code for this ,can send by email [email protected]

paresh · 2 years ago · Reply

Hi,I need the code & simulation very badly please send code [email protected]

Humayun · 2 years ago · Reply

Hi Hassam,
I`m a student in electronics (Germany) and build youre "distance measurement device".
would like to have a sw/code to [email protected].

Thanks !

Manuel
Manuel · 2 years ago · Reply

Hi,
I need the code & simulation very badly😐
[email protected]
Sibdat · 2 years ago · Reply

You may also like

POWERED BY
Disco Pattern LEDs using Microcontroller
https://hassam794.weebly.com/distance-measurement-device-using-ir-sensor-with-pic-microcontroller.html 4/5
12/11/2020 Distance Measurement Device using IR Sensor with PIC Microcontroller

Password Based Security Door Lock System

Microcontroller Based Distance Measurement Project

POWERED BY

https://hassam794.weebly.com/distance-measurement-device-using-ir-sensor-with-pic-microcontroller.html 5/5

You might also like