These are obstacle detecting glasses. They have an ultrasonic distance sensor mounted on the front that measures the distance to objects in front of you, and a buzzer that starts beeping faster and faster as the objects get too close. Many visually impaired people use canes to detect obstacles as they walk, and you can put ultrasonic sensors on these too. Well, you could put an upward-facing sensor on the tip of the cane, In general, these are best for detecting obstacles at ground level. They won't warn you if you're about to do something like walk into a tree branch or bend over and hit your head on a table.
The advantage of having a sensor mounted on glasses or a headset is that it will detect obstacles at face level and can also allow hands-free operation. Let's take a look at how this is built. As you can see, I just have all of the electronics mounted to a pair of safety glasses with either double-sided foam tape or electrical tape. I have an Arduino Uno, which we will talk about in a second, the ultrasonic distance sensor, a buzzer, a 9-volt battery, and an inline power switch with a barrel jack connector so you can turn the whole thing on and off.
If you've used Arduino before, you are probably ready to ask why I would use an Arduino Uno for this, since it's huge and this whole thing is mounted on a pair of glasses, so ideally you would want it to be more compact and lightweight. And the answer is that we are a K-12 STEM education non-profit. Our projects are intended for students who are new to Arduino, and the Uno is the most commonly available and introductory board. So you could certainly shrink this down and use a smaller, more compact Arduino. but for demonstration purposes, like if you were building a prototype of this for a science fair, using an Uno is fine.
These buzzers are also pretty loud, and having one right in your ear like that can be a little unpleasant, so it would also be easy to switch the buzzer out for something like a vibration motor to give the user tactile feedback or a vibration when they approach an obstacle instead of the beeping. The code and the circuit are nearly the same in both cases. We're going to switch over to the computer to take a look at that. You can get this full parts list circuit diagram and example code from the link in the video description But I will go over it here.
The circuit is very simple It just has two parts and you don't even need a breadboard because you can just plug the parts directly into the Arduino So that is why I have the diagram shown without a breadboard here We just have the ultrasonic distance sensor the HCSR04 which has four pins VCC for power that gets connected to five volts trig for the trigger pin that is connected to Arduino pin 6, echo for measuring the return pulse that is connected to pin 7, and ground which is connected to ground. We then have the buzzer which just has its negative lead plugged directly into this ground pin on the Arduino and the positive lead plugged into pin 11. If you look at the code which again you can download from the link in the description so I'm just going to go over it very quickly here. We have constant variables defined for the pins that the hardware is connected to. We have a threshold variable.
This is the distance in centimeters at which you want the buzzer to start beeping. And then we have some delay variables that are going to control the speed of that beeping and make the buzzer beep faster as an object gets closer. We have variables for the duration of the time it takes the ultrasonic pulse to return to the sensor.
and the distance in centimeters. In the setup function we use the pin mode command to set inputs and outputs for the buzzer and the ultrasonic distance sensor. Then in our loop function we send a trigger pulse to activate the sensor.
We then read the duration of the return pulse and we convert that time to a distance in centimeters. Now here's the key part of the program that converts that distance to the beeping noise. We have an if statement that checks if the distance in centimeters is less than the threshold variable that we set. If that is true, then we are going to use the Arduino map function to convert the distance in centimeters, which has a range between zero and the threshold variable, to a time between two different variables called buzzer delay min and buzzer delay max, which we set up here at the beginning of the program.
So, as the distance in centimeters variable gets smaller, the delay is also going to get smaller and the beeping is going to get faster. Because after that mapping function, we then have a digital write to turn the buzzer on, a delay for the buzzer delay variable, and a digital write to turn the buzzer off. and then another buzzer delay variable.
So as this buzzer delay variable gets bigger or something gets farther away, this delay is going to get longer and the beeping will be slower. As the buzzer delay variable gets smaller, then this delay will be shorter and the beeping will be faster. We then have the else part of our if statement.
If the centimeter value is greater than or equal to this threshold, we are just going to turn the buzzer off and it's not going to beep at all. Remember that if you want to build one of these yourself, you can find all the information you need in the video description. And for over a thousand other projects in all areas of science and engineering, check out our website, www.sciencebuddies.org.