I first started to code the project by one piece at a time. First the ultrasonic sensor, then the beep sound and then connected those together. Here i'm currently in test environment.
Next I had to hot glue all the parts to an old peaked cap and solder few wires together.
Then I tested if the parts still work without computer test environment and it didn't. I had to change the speaker connection a little bit and then it worked. Here is the final ultrasonic hat. The battery plus wire was too short but it is just long enough to work.
Testing phase for distance and beep to function correctly together.
And here it is. The final version of my prototype hat for the blind people or drunk people or what ever.
And how I coded it ? Here is the whole code.
Connection like in ultrasonic sensor post and tone post. hc-sr04 vcc to +5v, gnd to gnd, trig to pin 12, echo to pin 13. Speaker element goes to ground and digital pin 8.
//define the pins for ultrasonic sensor here
#define trigPin 12
#define echoPin 13
//setup trig is output and echo is input for the sound. Read serial fastest possible speed
void setup() {
Serial.begin (115200);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
//below methods for beep speed
void beepFast(){
// play a note on pin 8 for 200 ms:
tone(8, 440, 200);
delay(50);
// turn off tone function for pin 8:
noTone(8);
delay(300);
}
void beepSlow(){
tone(8, 440, 200);
delay(500);
noTone(8);
delay(300);
}
void beepMedium(){
tone(8, 440, 200);
delay(200);
noTone(8);
delay(300);
}
//no beep here
void beepNo(){
noTone(8);
delay(300);
}
//send a pulse and calculate how long it took to travel
void loop() {
int duration, distance;
digitalWrite(trigPin, HIGH);
delayMicroseconds(1000);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
//then check the distance and beep if it is in the range
if (distance >= 200 || distance <= 0){
Serial.println("Out of range");
}
else if (distance >=0 && distance <=30){
beepFast();
Serial.print(distance);
Serial.println(" cm");
}
else if (distance >=31 && distance <=60) {
Serial.print(distance);
Serial.println(" cm");
beepMedium();
}
else if (distance >=61 && distance <= 90){
Serial.print(distance);
Serial.println(" cm");
beepSlow();
}
else {
beepNo();
Serial.print(distance);
Serial.println(" cm");
}
}
And the guy behind this blog and random hat project...
Testing phase. She managed to walk to the door from kitchen and back. Succeed.
The project was fun to do and i'm proud that I managed to complete it. One thing more to add my portfolio.
hi Niki how r u ??
VastaaPoistaI really really need ur help ... in my arduino uno project ... and from more than 2 months I was searching somebody to help me ... then I found ur page ...
my idea is this .... 3 ultrasonic for 3 directions .. right , left and straight...
for the blindness people ....
if any object will be in front any ultrasonic the speaker will say the direction .. for example .. if in right direction the speaker will say right to make the person not collide the object..... and the same for the rest .....
my code is this ...
this my code ... i have problems in sketch it is too big ... i have to delete some from the PROGMEM . but which numbers i have to delete ... thanks
I didn't leave any person i didn't ask ... plz help me
I sent the code to ur facebook
Hello ! I am doing just fine =) My original idea was to use 3 ultrasonic sensors but I just only got one before I run out of time. I am sorry but I don't accept random facebook friends. However you can use http://pastebin.com/ to insert your code here. I am not very talented programmer so I am not sure if I can help you out, but we can give a try. I also actually ordered a better sound chip thing for my project but I got it way too late so maybe I should try it some day. Here it is:
Poistahttp://www.ebay.co.uk/itm/Mini-SD-Card-MP3-Sound-Module-For-PIC-Arduino-WTV020-SD-16P-/300851330313?pt=UK_Toys_Games_Outdoor_Toys_ET&hash=item460c22fd09
You can't use tone code to "speak" it needs some kind of mp3 samples and I would like to do my project with 3 ultrasonic sensors + mp3 module =) Send me your code through pastebin and I will have a look.
hi Niki ... first I wanna thank you for showing us your project.. Its very useful and helpful >>>GOD bless you :D
PoistaI will start my graduation project which is like yours in a Walking stick, but with 3 sensors and to add a headset that tell the blind the right direction ,, so I need a wireless system , like bluetooth to send user the right direction , what do u think?
do you have a code for 3 sensors ?
Hi ! You are welcome. I hope you find this post useful =) As you can see in my comment above my original idea was to use at least three sensors but I didn't have time to get all the sensors. If you are doing graduation project you should use your own code for the project and also I don't have code for three sensors because I didn't have time to wait all the sensors to arrive from post :( but yeah I think some kind of help tool for blind people would be a good project!
PoistaKirjoittaja on poistanut tämän kommentin.
VastaaPoista