Bike Alert
![bike8.jpg](/proxy/?url=https://content.instructables.com/FM8/EEXK/HIW8MS0A/FM8EEXKHIW8MS0A.jpg&filename=bike8.jpg)
This morning, while riding my bike, I thought, "Wouldn't it be nice to know when someone is approaching from behind?" I didn't want to use mirrors or funny glasses, so I decided to use an ultrasonic transducer to trigger a buzzer when approached.
This involves a Ping transducer, Arduino, buzzer, switch, 9 volt battery and enclosure.
Thanks to the world of 3D printing, these things don't have to be force fit into a black box anymore.
For the design and print files of the box (created in Autodesk's 123d software--free):
http://www.thingiverse.com/thing:115074
This involves a Ping transducer, Arduino, buzzer, switch, 9 volt battery and enclosure.
Thanks to the world of 3D printing, these things don't have to be force fit into a black box anymore.
For the design and print files of the box (created in Autodesk's 123d software--free):
http://www.thingiverse.com/thing:115074
![bike1.jpg](/proxy/?url=https://content.instructables.com/FST/3MBX/HIW895UZ/FST3MBXHIW895UZ.jpg&filename=bike1.jpg)
I started by piling the major components together to see what sort of space it would take.
![bike3.jpg](/proxy/?url=https://content.instructables.com/FJZ/EGD9/HIW8L7LB/FJZEGD9HIW8L7LB.jpg&filename=bike3.jpg)
![bike2.jpg](/proxy/?url=https://content.instructables.com/FHL/TTM1/HIW8L7L7/FHLTTM1HIW8L7L7.jpg&filename=bike2.jpg)
I followed by creating a box--sort of banana shaped instead of rectangular.
![bike4.jpg](/proxy/?url=https://content.instructables.com/FXN/3SS8/HIW8FQHS/FXN3SS8HIW8FQHS.jpg&filename=bike4.jpg)
![bike5.jpg](/proxy/?url=https://content.instructables.com/FZ0/34O1/HIW8OC6X/FZ034O1HIW8OC6X.jpg&filename=bike5.jpg)
I added the transducer, buzzer and switch. I didn't get my spacing quite right on the transducer, so I just fit one of the elements into one of the box holes.
![bike9.jpg](/proxy/?url=https://content.instructables.com/FJK/05Q0/HIW8FQHT/FJK05Q0HIW8FQHT.jpg&filename=bike9.jpg)
The wiring is fairly minimal, just follow the schematic.
Here is the code for the Arduino:
Here is the code for the Arduino:
const int pingPin=7;
long duration;
const int buzzer=3;
void setup()
{pinMode(buzzer,OUTPUT);
}
void loop()
{pinMode (pingPin, OUTPUT);
digitalWrite (pingPin, LOW);
delayMicroseconds (2);
digitalWrite (pingPin, HIGH);
delayMicroseconds (5);
digitalWrite (pingPin, LOW);
pinMode (pingPin, INPUT);
duration = pulseIn (pingPin, HIGH);
if (duration > 12000 and duration < 20000)
{digitalWrite (buzzer, HIGH);
delay(2000);
digitalWrite (buzzer, LOW);
delay(1000);
}
else
{digitalWrite(buzzer,LOW);
}}
![bike6.jpg](/proxy/?url=https://content.instructables.com/FZD/GBN4/HIW895V0/FZDGBN4HIW895V0.jpg&filename=bike6.jpg)
![bike7.jpg](/proxy/?url=https://content.instructables.com/FG0/FQXQ/HIW8QBSK/FG0FQXQHIW8QBSK.jpg&filename=bike7.jpg)
Connect everything together and close the lid with a wood screw.
![bike8.jpg](/proxy/?url=https://content.instructables.com/FM8/EEXK/HIW8MS0A/FM8EEXKHIW8MS0A.jpg&filename=bike8.jpg)
Secure to your bike in whatever way is appropriate--I use velcro.