Your cart is currently empty!
arduino interfacing sonar and buzzer vibration
I HOPE YOU ARE DOING WELL, Today, I would like to share the
Arduino Nano project Named Ultrasonic Sensor using Arduino Nano
which may use for the help of blind persons by fixing sonar sensor on
front of his glasses when any object comes on his front while walking
the buzzer, and vibrator start Alarming and its intensity vary by the
changing of distance between object and ultrasonic sensor
Ultrasonic Sensor Using Arduino Nano
arduino interfacing sonar and buzzer vibration
The Ultrasonic sensor, also known as SONAR, which sends ultrasonic waves that reflect back
after that helps us to measure distance by counting the time ,that makes it great for evaluate distance.
light detector circuit diagram in Proteus
Arduino DHT11 4Relay and LCD display
Variable half wave power supply circuit using 7805 regulator in proteus
earthquake alarm project explanation
Code
To upload code to your Arduino Nano:
Open Arduino IDE, paste your C/C++ code.
Connect Nano via USB, choose board and port.
Verify code for errors (checkmark), then upload (right arrow).
Disconnect Nano, apply power source for execution.
#define TRIGGER_PIN 7
#define ECHO_PIN 6
#define BUZZER_PIN 4
#define VIBRATOR_PIN 10
void setup() {
Serial.begin(9600);
pinMode(TRIGGER_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
digitalWrite(BUZZER_PIN, HIGH);
pinMode(VIBRATOR_PIN, OUTPUT);
digitalWrite(VIBRATOR_PIN, HIGH);
}
void loop() {
long duration, distance;
digitalWrite(TRIGGER_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIGGER_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIGGER_PIN, LOW);
duration = pulseIn(ECHO_PIN, HIGH);
distance = (duration / 2) / 29.1;
Serial.print(“Distance: “);
Serial.print(distance);
Serial.println(” cm”);
if (distance < 20) {
digitalWrite(BUZZER_PIN, LOW);
delay(500);
digitalWrite(BUZZER_PIN, HIGH);
}
if (distance < 20) {
digitalWrite(VIBRATOR_PIN, HIGH);
delay(500);
digitalWrite(VIBRATOR_PIN, LOW);
}
if (distance > 20 &&distance <30) {
digitalWrite(BUZZER_PIN, LOW);
delay(300);
digitalWrite(BUZZER_PIN, HIGH);
}
if (distance > 20 &&distance <30) {
digitalWrite(VIBRATOR_PIN, HIGH);
delay(300);
digitalWrite(VIBRATOR_PIN, LOW);
}
if (distance > 30 &&distance <40) {
digitalWrite(BUZZER_PIN, LOW);
delay(100);
digitalWrite(BUZZER_PIN, HIGH);
}
if (distance > 30 &&distance <40) {
digitalWrite(VIBRATOR_PIN, HIGH);
delay(100);
digitalWrite(VIBRATOR_PIN, LOW);
}
if (distance > 40 &&distance <50) {
digitalWrite(BUZZER_PIN, LOW);
delay(50);
digitalWrite(BUZZER_PIN, HIGH);
}
if (distance > 40 &&distance <50) {
digitalWrite(VIBRATOR_PIN, HIGH);
delay(50);
digitalWrite(VIBRATOR_PIN, LOW);
}
if (distance > 60 &&distance <80) {
digitalWrite(BUZZER_PIN, LOW);
delay(30);
digitalWrite(BUZZER_PIN, HIGH);
}
if (distance > 60 &&distance <80) {
digitalWrite(VIBRATOR_PIN, HIGH);
delay(30);
digitalWrite(VIBRATOR_PIN, LOW);
}
delay(100);
}
Pins Description of Ultrasonic Sensor
Pin Name Description
Vcc Voltage supply 5v
Trig Trigger pulse input
Echo Echo pulse output
GND Ground
Hardware components
Arduino Nano × 1
9V battery (generic) × 1
Vibrating motor × 1
Ultrasonic Sensor (HC-SR04) × 1
Jumper wires × 1
Toggle Switch × 1
Explanation of diagram:
Construction:
Connect the VCC pin of the ultrasonic sensor to the 5V pin on the Arduino.
Connect the GND pin of the ultrasonic sensor to any GND pin on the Arduino.
Connect the TRIG pin of the ultrasonic sensor to digital pin 7 (or any other available digital pin) on the
Arduino.
Connect the ECHO pin of the ultrasonic sensor to digital pin 6 (or any other available digital pin) on the
Arduino
Connect the positive (+) terminal of the buzzer to any 5v pin on the Arduino,
Connect the negative (-) terminal of the buzzer to digital pin 4 (or any other available digital pin) on the
Arduino.
Connect the USB cable from the Arduino to your computer to enable serial communication.
Connect one terminal of the vibrator motor to digital pin 10 on the Arduino.
Connect the other terminal of the vibrator motor to any GND pin on the Arduino.
Connect the positive terminal (+) of the 9V battery to the Vin (voltage input) pin on the Arduino through
toggle switch.
Working:
Working of this module is as follow:
1. After connecting all the components according to the diagram and install program in Arduino
Nano
2. Press the start button
3. When you place hand on the front of ultrasonic sensor in range in range (0-80cm), Led turns
ON , Buzzer start beeping and vibrator start vibrating
4. The intensity of buzzer and vibrator motor will change by the variation of distance between
hand and sensor
Application:
This sensor can be used in a lot of applications like:
Distance Measurement
Obstacle Detection and Avoidance
Liquid Level Sensing
Proximity Sensing
Positioning and Localization
Medical Imaging
Security Systems
Flow Measurement
Weather Monitoring
Quality Control
Underwater Applications
Fish Detection
IOT Devices
Automated Guided Vehicles (AGVs)
Material Handling