Using an Ultrasonic Sensor to Create a Haptic Guide
Contrary to popular belief, many who are visually impaired are actually very mobile on their own. Only 2 to 8 percent of people who have lost their sight use a cane as a guide. The rest use a sighted guide or a dog.
However, getting around crowded cities can still be a task. Not because of their disability, but because of the people around them who are unaware or simply don’t care about their surroundings. There are also objects located around many cities, such as traffic lights and stairs, that can increase the difficulty of navigation. These factors can pose a potentially dangerous situation for the 285 million people in the world who are blind.
Current aids that are meant to assist the visually impaired, such as the canes or dogs mentioned earlier, can also be limiting because they are like an added accessory.
So how can we allow the visually impaired to keep their independence while still assuring their safety as they go about their day to day activities?
Two words: Haptic Technology.

Haptics: Utilizing the Sense of Touch
Haptics is the use of technology to stimulate the sense of touch. Think about playing a shooting game on an X-Box, for example. When you push the button and the gun starts to shoot, the remote will start to vibrate. This makes the video game all the more engaging and realistic because it feels like you are shooting a gun.
The use of vibrations in the remote control is an example of haptic technology. The controller itself is a haptic device because it is what the user holds or interacts with to feel the vibrations. Besides gaming, haptics can be applied to a plethora of other fields to help improve the quality of life of others.
Creating a Haptic Device to Aid the Visually Impaired
Back to the original topic of this article, by utilizing haptic technology, we can actually create a guide for the visually impaired that helps them understand where others are relative to their position at a specific point. I decided to create a haptic device that uses different patterns of vibrations to let the user know how close or far objects, animals, people, etc. are.
There are two main components to the project: the actual vibration motors that’ll do the vibrating, and an ultrasonic sensor that’ll detect the distance of different objects around the user. Both, I will explain further down.
Implementing an Ultrasonic Sensor and Vibration Motors — Conception
Using an Ultrasonic Sensor to Calculate Distance
An ultrasound is a type of sound that is so high pitched that humans can’t hear it. The ultrasonic sensor is able to measure the distance between it and another object by sending and receiving these ultrasonic sound waves.
Think of it as a trampoline. If you jumped on a trampoline, you could go as high as you wanted since there is nothing blocking you above. But if there was some kind of object, like a roof, above you, you would bounce back to the trampoline much faster. This is similar to the way an ultrasonic sensor works.
Essentially, there are two ultrasonic transducers on the sensor (the base of the trampoline) that convert energy into an ultrasonic wave. One is a transmitter, and the other is a receiver. The transmitter sends out these ultrasonic waves. When there is an object in front of the sensor, these waves bounce back to the receiver. The time it takes for the wave to travel and then bounce back is called the time delay and it can be used to calculate the distance.

Ultrasonic sound waves travel at the speed of sound, which is about 343 meters per second (0.0343 cm per second) at 20 degrees Celsius. To calculate the distance, you need to divide the time delay by two since we only need the time it took to bounce back. So if you put all this in an equation:
Distance = (time delay ÷ 2) x speed of sound (cm/s)
And that’s how you can use the ultrasonic sensor to calculate how far an object is. The sensor is pretty accurate, the only issue being its limited range of 500 cm. While it was great for testing, in a real-world application, calculating the distance of an object only up to 500 cm away wouldn’t be very helpful.
Distinguishing Distance with Vibrations
When a person is visually impaired, it can be difficult to recognize the distance between an object and themselves, which can be dangerous, especially in crowded areas. As an alternative, I used vibrations to help them understand how far something is.
As I mentioned earlier, the range of the ultrasonic sensor is limited, so I had to set the ranges for the vibrations within 500 cm:
- One quick vibration: No object in the way. Clear for > 500 cm (16.4 ft)
- Two vibrations: An object is 300 - 500 cm away (9.84 to 16.4 ft)
- Three vibrations: An object is 150 - 300 cm away (4.92 to 9.84 ft)
- Rapid vibrations: An object is < 150 cm away (2.95 ft)
Implementing an Ultrasonic Sensor and Vibration Motors — Building Hardware
To build the haptic device I utilized an Arduino Nano (a small-sized microcontroller), an ultrasonic sensor, one coin vibration motor, one half-sized breadboard, and 4 jumper wires.
Note: The breadboard is used to transfer energy between the Arduino and sensor through the jumper wires.
Here’s a quick diagram of the Arduino Nano and its features:

Digital pins are the parts of the Arduino Nano that are labeled with numbers 1–13. They can either input or output When used as an output, they can provide an energy current to other parts of the board that are connected to them through a jumper wire
The sensor can be connected to the Arduino following this schematic:

The vibration motors can be added on by just putting them in any digital pin on the Arduino.
Notes and Explanations:
- The ultrasonic sensor needs 5 volts of energy in order to create a sound wave. This is why the 5 volts of the sensor (the section of the sensor that says VCC) are connected to the Arduino board’s 5-volt output.
- Earlier I mentioned that an ultrasonic sensor has a transmitter and a receiver. These are marked as trig (trigger) and echo on the sensor. (The trigger is the transmitter and the echo is the receiver.) These can be connected to any digital output pin on the Arduino board. The same goes for the vibration motors. (In my case I used pin number 3 for the motors.) This is because all the digital output pins provide the same amount of energy to other circuits when used.
- GND means ground. The section that says “ground” on the sensor must always be connected to where it says “ground” on the Arduino.
- Remember: You connect sections of the Arduino to the sensor using a jumper wire. As shown in the image above, you place the wires in the section of the breadboard that is next to the spot in the Arduino that you need to use.
And that’s it for the hardware!
Implementing an Ultrasonic Sensor and Vibration Motors — Programming
The final step is to program the hardware. I did this in the Arduino IDE.
Programming the Sensor
First I started with the sensor. I needed to program it so that it could calculate the distance of an object.
There are several methods to program the sensor. Originally I used the “pulseIn” function that came with the IDE. It measures the duration of a pulse (the time it takes for a sound wave to be transmitted and then bounce back). However, I found a library (a function not already in the IDE that can be added to it). This made the coding much simpler and also the results much more accurate. (It can be downloaded here.)
This is a screenshot of the first part of the program with an explanation:

A More In-Depth Explanation of the Program for the Sensor
The NewPing library comes with functions that can be easily used and only require that we add the variables we need to them. In the first few lines, I just define those variables and import the NewPing library.

The function #define trigPin 10, defines which digital output pin on the Arduino you connected the “trig” part of the sensor to. Same for the echoPin. The int motorPin = 3 function does the same thing, but this time it defines the location of the red wire of the vibration motor.
As I mentioned earlier, the NewPing library comes with functions that allow you to simply add the variables that you need to it:
NewPing sonar(trigger_pin, echo_pin, [max_cm_distance])
NewPing sonar is the name of the function. It takes the value you put for the “trigPin” and sends energy to the digital output pin that matches that value. This will cause the sensor to send out a “ping” or a sound wave through the trigger. Next, it will do the same for the echoPin. However, the echoPin will receive the ping from the trigPin. The part of the function that says [max_cm_distance] is where you put the maximum distance you want the ping to travel. (Because of the restraints of the sensor, the maximum distance can not be greater than 500 cm.)
In my case, since I already defined the values of the trigPin, echoPin, and MAX_DISTANCE at the start of the code, I can just insert the names of these variables into the function. (This makes it easier later on if I ever change the digital output pins for the trig and echo pins):

Next, I need to create a variable for the duration and distance of the ping as well as set up the monitor where I can see the distance in centimeters that the ping traveled.

I create the variables for the duration of the ping and the distance of the ping in line 13.
Then I set up the serial monitor in line 16. This will open up a window in the Arduino IDE where I can see the values being output by the sensor. (The distance between the sensor and an object).
Continuing on, I have to set up a loop. Anything inside the loop will continuously occur until the program stops:

First, I use the delay(50) function. This will cause the rest of the program to be delayed by 50 milliseconds between each ping. Next, I set a value for my duration variable by using the sonar.ping_cm() function that comes with the NewPing library.
This function basically sends a ping out from the trigger and then returns the duration of the ping. Then I set the distance by using the equation from above.
The final part in lines 24–26 is where I just print out the distance that the sound wave traveled by using Serial.print(). This will print out whatever is in the parenthesis in the serial monitor, where I will then be able to see what the distance of an object is from the sensor.
Programming the Vibration Motors
Now, continuing on to the next part where the motors are programmed to vibrate according to the distance calculated. Here’s the code with the explanations:


A More In-Depth Explanation of the Program for the Vibration Motors
This part of the code goes directly under the code for the sensor. It is a series of if statements based on the parameters that I mentioned earlier.

When assembling the pieces, I mentioned that I put the motor in digital output pin 3, and put this in a variable called motorPin. This is where the variable is being used. This part of the code says that if the distance is greater than 500 cm, then only vibrate once.
The digitalWrite() function controls the digital output pins. You have to insert the number of the digital output pin that you want to control. (Since I already defined that motorPin = 3 earlier on, I can just put the name of the variable in the parenthesis.) Once you do this you can set that pin to HIGH or LOW. High means that it turns on, and low means that it turns off. So, the code above basically says, “if the distance is greater than 500 cm, turn the motors on for 500 milliseconds (half a second), then turn them off.”
The same function is used throughout the rest of the code. I can vary the number of vibrations by just changing the number of times I turn the vibration motors on and off.
And… we’re done!
Things to Consider Later On
Some things that I noticed and took note of while creating and playing with this device were:
- On average, a person walks 134 cm per second. So to get to an object 500 cm away it would only take a little over 3 seconds. In reality, this is too close of a range to really help prevent accidents, but for the sake of this project, I just stuck with the 500 cm. In the future, I would work on extending the range of the sensor so that it could sense objects much farther away.
- To be way more effective, the sensors would need to be able to calculate the distances of objects that are all around the user. This would mean I would have to find a way to add more sensors to the device.
- In crowded areas, when there are many people, I wouldn’t want the device to continuously go off. Instead, I think I would edit the program so that if there are obstacles that stay within a certain range for a period of time it wouldn’t continue to vibrate.
- While the Arduino Nano and the sensor are small, I would need to find a way to decrease the size even more so that it could be a comfortable wearable that doesn’t become another accessory.
Looking Towards the Future
There are an estimated 285 million people in the world who are visually impaired. Creating this device could not only guarantee more safety, but also give them a greater sense of independence.
I learned a lot through this project, and realized that the solution to the problem I wanted to solve is not as simple as I thought. There are so many variables to take into consideration. However, I know I can improve through more practice.
While a cure for blindness is not yet available for all, we can still improve the lives of those with visual impairment through technology.
Hold up… Before you leave:
Did you like this project and want to see more from me? Connect with me here: