Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Arduino Project – Smart Blind Stick with Ultrasonic Sensor

In this project, we will make a smart blind stick for the blind person using Arduino and ultrasonic sensor.

An ultrasonic sensor is a device that uses high-frequency sound waves (ultrasound) to detect objects, measure distances, or detect changes in the environment. It emits sound waves and measures the time it takes to bounce off an object and return to the sensor.

Visit Exploring the Power of Ultrasonic Sensors: A Brief Introduction for more information.

Hardware Required

Arduino Nano

For more information, visit What is Arduino Nano? A Beginner’s Guide.

  • HC-SR04 Ultrasonic Sensor
Ultrasonic Sensor
  • Buzzer
Buzzer
  • 9 V Battery
9V Battery
Battery Connector
Switch
  • Jumper Wires
Jumper Wires
  • PVC Pipe
PVC Pipe

Diagram

Diagram of Smart Blind Stick

Setup

Smart Blind Stick
1. Upload the program

Connect the Arduino to your computer using a USB cable. Upload the program to the Arduino through the IDE software. Visit Getting Started with Arduino IDE: A Beginner’s Guide to Coding and Creating for more information.

2. Connect the ultrasonic sensor to the Arduino
Ultrasonic SensorArduino
VCC5V
GNDGND
TrigD9
EchoD10
3. Connect the buzzer to the Arduino
BuzzerArduino
Negative terminalGND
Positive terminalD5

The buzzer and ultrasonic sensor are connected to the same GND pin.

4. Connect the switch to the battery connector

Connect the switch, battery connector, and jumper wires as illustrated in the photo.

5. Connect the 9V battery to the Arduino
BatteryArduino
Negative terminalGND
Positive terminalVin

Logic

The Trig pin is set to a HIGH state, triggering the ultrasonic transmitter to emit a sound wave. At the same time, the Echo pin also goes HIGH, beginning to wait for the reflected wave. Once the sound wave bounces off an object and returns, the travel time is recorded. Using this time, the distance to the object is calculated with a specific formula. If the calculated distance falls within a defined range, the buzzer is activated to sound an alarm.

Code

// defines pins numbers
const int trigPin = 9;
const int echoPin = 10;
const int buzzer = 5;

// defines variables
long duration;
int distance;
int safetyDistance;

void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
pinMode(buzzer, OUTPUT);
}

void loop() {
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);

// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);

// Calculating the distance
distance= duration*0.034/2;

safetyDistance = distance;
if (safetyDistance <= 5){
  digitalWrite(buzzer, HIGH);
}
else{
  digitalWrite(buzzer, LOW);
}
pulseIn()

Reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, pulseIn() waits for the pin to go from LOW to HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns the length of the pulse in microseconds or gives up and returns 0 if no complete pulse was received within the timeout.