loading

This device or instructable is a helpful tool (as I think) to get your attention when you are driving especially in the night time. After a hard day work on the weekend, you may sometime have gathering and drive back home late night, you will easily felt sleepy or felt into a deep thought for forever reason and lost attention to the road traffic, or you need to drive a route you have never ride before, accidents come in easily.

The design idea is copied from real train operators, the major difference is the train operators if not action on the device, the train will stop itself automatically, the operator may get fired also automatically. For your interest, the train operators in Japan used another method, for every ten seconds of driving, the operator will stretch the arm straight pointing to a fast object outside the train and murmuring something like saying, that is a house, that is the mountain, that is a girl.............

This device has a three stage of alert, firstly is blinking of a LED for ten seconds, then it will blink another ten second with short buzzer sound, you may stop it and cycle back to stage 1, or else it will long blink and long beep to annoy you.

Step 1: The Circuit

The Arduino circuit is ease, you need a buzzer (non sourced), a push button and a bright LED, the push button must connected pin2 and ground, other components are free to mount.

Step 2: The Code

#define buzzer 7

#define led 13

#define button 2

void setup() {

// put your setup code here, to run once:

pinMode(button, INPUT_PULLUP);

pinMode(buzzer, OUTPUT);

pinMode(led, OUTPUT); }

void loop(){

loop1();

loop2();

loop3(); }

void loop1() {

noTone(buzzer);

for (int x = 0; x<=9; x+=1) {

digitalWrite(led,HIGH);

delay(1000);

digitalWrite(led,LOW);

delay(1000);

}

loop2();

}

void loop2() {

for (int x = 0; x<=9; x+=1) {

int val = digitalRead(button);

if (val==LOW) {

loop1();

} else {

digitalWrite(led,HIGH);

tone(buzzer,600,100);

delay(1000);

digitalWrite(led,LOW);

tone(buzzer,600,100);

delay(1000);

}

}

loop3();

}

void loop3() {

for (int x = 0; x<=2000; x+=1) {

int val = digitalRead(button);

if (val==LOW) {

loop1();

} else {

digitalWrite(led,HIGH);

tone(buzzer,1200);

delay(50);

digitalWrite(led,LOW);

tone(buzzer,600);

delay(50);

}

}

}

Step 3: Installation

I'm not sure if Arduino can direct plug into 12V car battery, to play safe add a voltage regulator like 7805 and be aware some cars run on 24V. The best place to place the device is on the top surface of the dash board, just as fast as your arm and finger can stretched to touch, do not install in easy access place, you may need to lean forward your body in order to see more.

From the video you find that the alert sound can be stopped in stage 2 and stage 3, but in stage 2 delay added so the reading of push button is also delayed, you may need to push and hold a second to stop it, you may change the duration and your favorite tone

If you feel the device is annoying you, yes, it is designed to annoy you!

About This Instructable

170views

3favorites

License:

More by martinhui:Easy Wire Wrap Tools ESP8266 Wall Clock LEGO Clock 
Add instructable to: