This project uses an HC-SR04 Ultrasonic sensor and an Arduino to measure the distance between the user and an obstacle and cause an LED, buzzer and motor to flash, beep and vibrate respectively to alert the user that he is approaching an obstacle. This device can be very useful to blind people and other people with some form of impaired vision.


An HC-SR04 ultrasonic sensor works with the Arduino to measure the distance between the device/user and an obstacle in front of it. Based on the distance between the device and the user, the LED flashes, the buzzer beeps and the motor vibrates. The most important thing to note here is that the intervals at which  the LED, piezo buzzer and DC Motor flash, beep and vibrate respectively is directly proportional to the distance between the ultrasonic sensor and the obstacle, hence the smaller the distance between the sensor and the obstacle in front of it, the faster the LED, buzzer and motor turn on and off and vice versa.

Components You’ll need

Here are the components you’ll need for this project

  • Arduino Uno
  • HC-SR04 Ultrasonic sensor
  • Solderless Breadboard
  • Small 5v DC motor
  • Piezo Buzzer
  • 1 Red LED
  • 1 220 ohm resistor
  • 1 1kOhm resistor
  • 1 BC547 NPN Transistor
  • 1 1N4001 diode
  • A number of male to male jumpers

If you live in Ghana, you can get these components from Invent Electronics. If you leave elsewhere, look for an electronics or hobby store near you.


Here is a breadboard circuit of the project designed in Fritzing.


Fritzing breadboard layout of the circuit


Here is another design and simulation of the circuit which I created in Proteus. There is a link to the Proteus file and other files and resources for this project at the bottom of the post.


Arduino Code

I have tried to comment the code as much as possible to make it very easy to understand, however parts of the code which may still be unclear are explained in the video. If you haven’t installed the Arduino IDE already, download and install from here

Final Circuit


Circuit assembled on breadboard


Circuit assembled on breadboard


Download this zipped file containing the resources needed for this project. It contains the following:

  • Arduino Sketch
  • NewPing library (Extract library into your Arduino Libraries folder).
  • Proteus Design File (You’ll have to extract the Arduino Library for Protues and Ultrasonic Sensor library for Proteus for the simultation to work. I used Proteus 7.8)
  • Arduino Hex File For Proteus

If you are interested in running the simulation and do not already have the Arduino Library for Proteus, The Engineering Projects created a cool library for that. Download both the Ultrasonic sensor library and the Ardino library for Proteus.

Like this tutorial? Found a mistake? Want to suggest improvements or corrections? Please leave us a comment.

%d bloggers like this: