# PROJECT 8 – ANALOG DISTANCE SENSOR TO LCD DISPLAY

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.

PROJECT 8

ANALOG DISTANCE SENSOR TO LCD DISPLAY

 Back to Project 7 Go to Project 9
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. E.g: adc_value = 1022, ~ if using adc_value*5/1024, Vout = 4 ~ if using adc_value* 500000/1024 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 Go to Project 9
———————————————————————————————————————————————————-

### ATTACHMENT

1. P8 User Manual.pdf 2. Project_8_code.zip

## Latest Tutorial

DIY Interactive Robot Using REKA:BIT With Micro:bit
BLTouch Installation for Ender 3 with 32-bit V4.2.2 Board
Pick and Send Random Meal’s Option and Locations through Telegram Bot Using Grove WiFi 8266 on micro:bit
DIY Automated Vacuum Cleaner Using REKA:BIT With Micro:bit
Rainbow Spark in Mini House using Maker Uno.
Scroll to Top