 Bukit Mertajam, Penang

PROJECT 8 – ANALOG DISTANCE SENSOR TO LCD DISPLAY

PROJECT 8

ANALOG DISTANCE SENSOR TO LCD DISPLAY

 Back to Project 7

Analog distance sensor, which are mainly use to measure the distance of an object. The advantage of this sensor is the accuracy of sensor can measure the object distance up to centimeter(cm). In this project, we going to interface this sensor to Arduino Deuemilanove and display the value it Arduino LCD Keypad shield.

COMPONENT NEEDED

———————————————————————————————————————————————————-

CONNECTION

———————————————————————————————————————————————————-
Analog distance sensor have 3 pins which is VDD, GND, Vout. Connect the Vout to analog pin-1GND to ground and VDD to 5V. 1-Vout      2-GND       3-VDD(+5V) ———————————————————————————————————————————————————-

———————————————————————————————————————————————————-

Referring to the chart above are the output voltage(V) versus distances(cm) of the analog distance sensor. By plotting the output voltage versus inverse number distance (1/cm), we can get the linear relation such as in figure below. The linear equation is y = 20.99x + 0.19, where y is voltage output and x invert distance. Notice that the trusted output voltage are about 0.4 to 2.8 V.

CODE OVERVIEW

———————————————————————————————————————————————————-

Vout = (range*500000)/1024;
Get the ADC value and apply formula where to make the value in voltage with larger value.
Vout = 4
Vout = 499023

if ((Vout > 43945) && (Vout < 279785))
Check the Vout value whether is between 43945 and 279785.

range = (Vout – 19000)/2099;
Determine the range by apply the formula given.
E.g-1 : if Vout = 279785
279785 – 19000 = 260785
1000 / 124 = 8 Set the LCD cursor and clear the value.

 Back to Project 7

———————————————————————————————————————————————————-

ATTACHMENT 