Ultrasonic Sensor

by Bob_3737 in Circuits > Arduino

100 Views, 1 Favorites, 0 Comments

Ultrasonic Sensor

WIN_20251126_00_32_54_Pro.jpg

I used C++ with Arduino to make an ultrasonic sensor with 5 colored LED's that show how far an object is from the sensor. Ultrasonic sensors use high frequency sound waves (ultrasound) which are invisible to the naked eye to measure distance. They send out a wave, and record how long it takes to receive it back. It then converts this into distance.

Springbank robotics

Supplies

image_2025-11-26_005132878.png
image_2025-11-26_005815508.png

Used an Elegoo Arduino starter kit, as well as an example program form the Arduino IDE that I tweaked into my own program.

Design a Circuit

image_2025-11-26_010022748.png

Create a circuit in Tinkercad. I recommend doing the tutorial on how to use Tinkercad, and then watch video's on how to set up a circuit. Once you've done all the research you need and have a rough idea of what you're doing, put together a circuit of your own.

Build the Circuit

Screenshot 2025-11-26 005537.png

Now, look at what you have in Tinkercad, grab the real life equivalents of the Tinkercad parts, and start building the physical circuit using Arduino parts.

Code an Ultrasonic Program

image_2025-11-26_010205377.png

I recommend using the Youtube channel " science buddies" to learn about C++. Once you have your circuit, code a program in the Arduino IDE to make the circuit work. There's example programs you can learn off of already built into the IDE. The attached file is a program that uses 5 LED's that the sensor controls to project the distance of an object.

Downloads

Test/tweak

Now, plug the USB into your computer and begin to test out your program. This can be hard, because if there's a problem it can be hard to tell whether its the circuit or the code that has a problem. It is important to run a simulation in Tinkercad before you test, because this can tell you if your circuit is dangerous or will cause damage to and components. Once you get it to work, start experimenting, add more LED's, and get creative.