Hackster is hosting Hackster Holidays, Finale: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Tuesday!Stream Hackster Holidays, Finale on Tuesday!
Tim Gardner
Published © LGPL

Ultrasonic Glasses for the Blind

Sunglasses that serve an even more useful purpose than protecting the eyes of the blind. They can help them detect objects in front of them.

IntermediateFull instructions provided2 hours102,644
Ultrasonic Glasses for the Blind

Things used in this project

Hardware components

Arduino Pro Mini 328 - 5V/16MHz
SparkFun Arduino Pro Mini 328 - 5V/16MHz
Any version of the Arduino micro controller will work.
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Buzzer
Buzzer
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Sunglasses
×1

Software apps and online services

Arduino IDE
Arduino IDE
You can also use the Cloud IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Schematics

Ultrasonic Glasses Schematic

This is the schematic for the ultrasonic glasses. It uses an Arduino Pro Mini and the HC-SR04 ultrasonic sensor. It is powered by a 9V battery.

Code

Ultrasonic Glasses for the Blind

Arduino
This Arduino code uses the HC-SR04 ultrasonic sensor and an Arduino Pro Mini micro-controller. You can use any Arduino micro-controller with this code. The code detects the distance by converting the time in milliseconds that it takes for the sound waves to bounce back in distance in centimeters. It beeps intermittently if an object is within 62cm (about 2 feet). At 31cm (or about 1 foot away) its just one solid non-stop beep tone. The code is very simple in that it does not require additional hardware libraries outside of what is built in to the Arduino IDE.
/*
Arduino code used for the Ultrasonic Sensor Sunglasses

Jacob Gardner - 5th Grade STEM Engineering Project
*/

#define trigPin 8  // These lines assign names to values
#define echoPin 7  // so they can be easily identified.
#define buzzer 12  // These are set before the code

/* This section of code below runs only one time.
 * It enables the serial monitor to see output and
 * sets the pins to input or output.
*/ 
void setup() {
  Serial.begin (9600); 
  pinMode(trigPin, OUTPUT); 
  pinMode(echoPin, INPUT);  
  pinMode(buzzer, OUTPUT);
}

/* The remaining part of the code runs in a constant loop.
 * It triggers the ultrasonic sensor and calculates the
 * time it took for the sound waves to return.  It converts
 * the time in milliseconds into distance in centimeters.
 */
void loop() { 
  long duration, distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
  Serial.print(distance);
    Serial.println(" cm");
  
// This part of the code below determines whether to
// beep depending on the distance detected. If the object
// is within 62 start the beeps.
  
if (distance > 30 and distance < 62) { 
    tone(buzzer,100,50);  // Intermitten beeps
    }
    if (distance > 0 and distance < 31) { 
    tone(buzzer,100); // Long solid beep
  }
  else {
    }
  delay (500);
  
} 

Credits

Tim Gardner
3 projects • 28 followers

Comments