I need the code for blind stick that vibrates and alarm sound. I am using Arduino nano thank you
Welcome
That is not how this forum works. The helpers here provide guidance and assist in writing code. So you need to tell us what you are using to vibrate and make the sound and how it is connected to the Nano (schematic/wiring diagram), you need to show us what you've tried code wise and how the experienced behaviour differs from the expected behaviour.
If you are prepared to pay somebody, you can ask for the topic to be moved to Jobs and Paid Consultancy - Arduino Forum.
I googled that, resulting an 'AI Overview' and a link to a Destructables presentation.
I am certain a blind person will have much better experience using a normal "blind stick" than one that makes noise and requires batteries. If you are required to make an assistive product, design something for people without imparements. The idea of novices designing for cripples is ingenious to the point of being ridiculous (full of ridicule). Design a can opener or live mouse trap or money counter or a freeze warning. These projects serve the purpose of design and engineering, and stops you from benefitting off "those poor cripples."
Do you already have the vibrator and the alarm sound device you want to use? If not, you cannot begin to even design a program or the support circuitry to go with it.
I have everything and attached to Arduino Nano already. My problem is it has a "clicking or flickering" sound.
Relax, this is not for commercial. This is just for the students' Science Fair project. I don't mean to offend disabilities. I am an advocate for disabilities as well. This is not too serious, but it has to work somehow. There was a flickering or clicking sound.
long duration;
int distance;
int safetyDistance;
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(buzzer, OUTPUT);
pinMode(motorPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance= duration*0.034/2;
safetyDistance = distance;
if (safetyDistance <= 30){
digitalWrite(buzzer, HIGH);
digitalWrite(motorPin, HIGH);
}
else{
digitalWrite(buzzer, LOW);
digitalWrite(motorPin, LOW);
}
Serial.print("Distance: ");
Serial.println(distance);
}
What Buzzer are you using , there is mechanical that opperate thru a contact.
Then there is a Piezo that needs a tone ,high and low pulses and the third have a build in pcb that generate the tone and the pins is marked .. POS +.. NEG -
I think the connection is working now. My problem is ... it never stops vibrating and beeping. how can I solve this. Thank you
You never reply to this.
No wiring diagram.
Its working now.
What did you change?
You did not post changes in your code.
Nobody will know why , we cannot see what you did.
I suspect the yellow wire.
What did you plan to make it stop? Did you only plan to make it begin vibrating and beeping? What conditions should occur to make it stop?
I am using bz 1295 active buzzer. but it's not loud it's just a click sound. I will change to KY 006 Passive buzzer
This is the code now.
// Pin Definitions
int trigpin1 = 8; // Trigger pin for Ultrasonic Sensor 1
int echopin1 = 7; // Echo pin for Ultrasonic Sensor 1
int trigpin2 = 10; // Trigger pin for Ultrasonic Sensor 2
int echopin2 = 9; // Echo pin for Ultrasonic Sensor 2
int BUZZpin = 3; // Buzzer pin
int Vmotor = 2; // Vibrating Motor pin
void setup() {
// Serial Monitor for debugging
Serial.begin(9600);
// Set pin modes for Ultrasonic Sensors
pinMode(trigpin1, OUTPUT);
pinMode(echopin1, INPUT);
pinMode(trigpin2, OUTPUT);
pinMode(echopin2, INPUT);
// Set pin modes for Buzzer and Motor
pinMode(BUZZpin, OUTPUT);
pinMode(Vmotor, OUTPUT);
// Ensure the buzzer and motor are off initially
digitalWrite(BUZZpin, LOW);
digitalWrite(Vmotor, LOW);
}
void loop() {
// Variables to store distances from the sensors
long distance1 = getDistance(trigpin1, echopin1);
long distance2 = getDistance(trigpin2, echopin2);
// Debugging: Print distances to Serial Monitor
Serial.print("Distance 1: ");
Serial.println(distance1);
Serial.print("Distance 2: ");
Serial.println(distance2);
// Logic for distance-based feedback
if (distance1 <= 80 || distance2 <= 80) {
// Moderate buzzing and vibration for distances <= 80 cm
activateFeedback(100);
}
if (distance1 <= 40 || distance2 <= 40) {
// Faster buzzing and vibration for distances <= 40 cm
activateFeedback(50);
} else {
// Turn off the buzzer and motor if no obstacles are detected
deactivateFeedback();
}
}
// Function to calculate distance from ultrasonic sensors
long getDistance(int trigPin, int echoPin) {
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; // Convert duration to distance (in cm)
return distance;
}
// Function to activate buzzer and motor feedback
void activateFeedback(int delayTime) {
digitalWrite(BUZZpin, HIGH);
digitalWrite(Vmotor, HIGH);
delay(delayTime);
digitalWrite(BUZZpin, LOW);
digitalWrite(Vmotor, LOW);
delay(delayTime);
}
// Function to deactivate buzzer and motor feedback
void deactivateFeedback() {
digitalWrite(BUZZpin, LOW);
digitalWrite(Vmotor, LOW);
}
I am planning to make the distance a bit longer/farther. maybe it is catching the ceiling that's why it vibrates
what is this mechanical that operates through a contact?
Seems strange that use use serial.Print() for several things, but never to debug your code!
Thank you. I am new user of arduino and this site. I am learning.
I understand that, but how did you get this far with the code without any debugging? After all these years, I still create bugs every 4-5 lines of code. Test/debug as you go.
I used chatgpt. for the code, I am learning. I am so new in arduino. and it interests me a lot. I like to study this further after I finish my students' project.