top of page

Distance Sensor Project Using Ultrasonic Sensor And Arduino

  • Writer: Lara Vaidya
    Lara Vaidya
  • Aug 15, 2020
  • 1 min read

This is a simple Arduino project using an ultrasonic sensor. The ultrasonic sensor transmits and receives ultrasound waves to measure the distance from objects in front of the sensor. Here, I am using LED lights and a buzzer to indicate how close an object is. It can be used on a car to detect if there's an object and turn, or to help with parking.


Check out the Youtube video I made for this project.


Step 1: Materials

The materials for this project are simple:

Arduino UNO

Ultrasonic Sensor

1 Buzzer

3 LEDs

3 220 ohm Resistors

Wires

Breadboard

Step 2: Circuit

Here are some notes about each component that will help to understand them.

These are the fritzing diagrams for the ultrasonic sensor, led light, and buzzer.

This is how the circuit looks.

Step 3: Code

Here is the code I used for this project. The comments will guide you through the logic behind each step.

The code is checking for the distance through the ultrasonic sensor, using the Ultrasonic() function, and then saving the distance. If-else blocks determine what component is changes based on the distance. A certain light is turned on and the rate of the sound from the buzzer s changes based on the distance.


Here is a demonstration of the project working.

If you tried out this project, let me know how to go in the comments below or my Youtube video. This project can be modified to fit many problems, so see what you can change to make it your own.

תגובות


  • redbubble-logo_edited
  • 5de404f55f17623c6b3b2713_TikTok-logo-com
  • YouTube
bottom of page