Arduino Electronics Design Electronics Programming XE Week 10 - Intro to Arduino and Flashing LEDs XE Week 12 - Range Finder & Display

Arduino LCD & Ultrasonic Rangefinder

This is the final week and final task of the XE digital fabrication module.

The challenge this week was to build on our Arduino knowledge from the previous weeks and to connect an Ultrasonic Range Finder Unit (URF) to the Arduino.

A URF uses sound to detect the distance of the sensor to an object by using the speed of sound (S) and time (T) to calculate distance (D). D = S x T

ultrasonic range finder

The URF has 4 connection pins:

  • VCC
  • TRIG
  • ECHO
  • GND

I am using the LCD to display the distance and it is connected as detailed in the the previous post.  The LCD occupies the +5V and GND pins on the Arduino that you would expect to use for the VCC and GND of the URF. To work around this I connected the URF as shown in the image below and adjusted the code accordingly.

URF connection

 

I used the digital connections 8 – 11 and change the code to reflect this:

  • On lines 9 and 10 the trig and echo pins are defined and they are set up on lines 22 and 23.
  • On lines 20 and 21 the GND and VCC are set up to power the URF via pins 11 and 8.

code adjustment

 

This is the complete code that works alongside the LCD library to make the whole thing run – https://create.arduino.cc/editor/ohafoahspjpoid/95c16f40-c4d7-449e-8301-83ca1306d480/preview

 

With RFU and the LCD set up and running I has a quick experiment with the accuracy of the RFU. I used a flat piece of metal to try and find the point at which the RFU started to register a distance and extended a measuring tape from that point.

RFU measurement set up

RFU measure

RDU 20cm

I found that it as accurate against the tape measure by about ±0.5cm and the accuracy was very reliant on the flat surface I was using to be perfectly vertical.

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *

Powered by: Wordpress
Skip to toolbar