Build obstacle detecting glasses for visually impaired people
Posted: Thu Oct 15, 2026 6:15 pm
After completing the experiment, the buzzer is not beeping at all. Attaching picture for reference.
I have made changes to the ping code and uploaded code to the buzzer as well.
Is this code correct?
const int trigPin = 7;
const int echoPin = 8;
void setup() {
Serial.begin(9600);
pinMode(trigPin,OUTPUT);
pinMode(echoPin,INPUT);
}
void loop() {
long duration, inches, cm;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
// convert the time into a distance
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
}
long microsecondsToInches(long microseconds) {
// According to Parallax's datasheet for the PING))), there are 73.746
// microseconds per inch (i.e. sound travels at 1130 feet per second).
// This gives the distance travelled by the ping, outbound and return,
// so we divide by 2 to get the distance of the obstacle.
// See: https://www.parallax.com/package/ping-u ... downloads/
return microseconds / 74 / 2;
}
long microsecondsToCentimeters(long microseconds) {
return microseconds / 29 / 2;
}
I'm also not sure how to test using breadboard version of the experiment i don't see any video tutorial or a good diagram to outline wires and connections properly.
Moderator Note:
SB Project: https://www.sciencebuddies.org/science- ... ng-glasses
SB Videos: https://www.sciencebuddies.org/science- ... an-arduino
I have made changes to the ping code and uploaded code to the buzzer as well.
Is this code correct?
const int trigPin = 7;
const int echoPin = 8;
void setup() {
Serial.begin(9600);
pinMode(trigPin,OUTPUT);
pinMode(echoPin,INPUT);
}
void loop() {
long duration, inches, cm;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
// convert the time into a distance
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
}
long microsecondsToInches(long microseconds) {
// According to Parallax's datasheet for the PING))), there are 73.746
// microseconds per inch (i.e. sound travels at 1130 feet per second).
// This gives the distance travelled by the ping, outbound and return,
// so we divide by 2 to get the distance of the obstacle.
// See: https://www.parallax.com/package/ping-u ... downloads/
return microseconds / 74 / 2;
}
long microsecondsToCentimeters(long microseconds) {
return microseconds / 29 / 2;
}
I'm also not sure how to test using breadboard version of the experiment i don't see any video tutorial or a good diagram to outline wires and connections properly.
Moderator Note:
SB Project: https://www.sciencebuddies.org/science- ... ng-glasses
SB Videos: https://www.sciencebuddies.org/science- ... an-arduino