Introduction: Arduino Scare Machine
The arduino scare machine is actually quite simple, but it also is great fun to have around.
WARNING: US AT YOUR OWN RISK. DO NOT USE ON PEOPLE WHO HAVE CERTAIN HEALTH ISSUES.
Have a scarring great time!
First, I took a sharp ir GP2Y0A21YK sensor and mounted it on my dresser with electrical tape. it detects when people, or anything for that matter, passes close to it. On the Arduino it's hooked up to A0.
Next I took my arduino and wrote the the code for it. I included a serial out put so you can calibrate it for yourself. The code is currently set for a few feet in front of the sensor. You also need to download a library for the sharp ir sensor. you can get the the library at http://code.google.com/p/gp2y0a21yk-library/ just follow the directions to install it. Here's the code for arduino.
DistanceGP2Y0A21YK Dist; // the sensor reading
int distance; //the distance in cm.
pinMode (10, OUTPUT); // pins we're using
pinMode (13, OUTPUT);
Serial.begin(9600); //start serial
distance = Dist.getDistanceCentimeter();
Serial.print("\nDistance in centimers: ");
Serial.print(distance); // for callibration
digitalWrite(13,HIGH); //turn lights on
delay (700); //give time to see lights
digitalWrite(10, HIGH); //turn stereo on
delay (3500); //let stereo on for a few seconds
digitalWrite(13,LOW); //turn lights off
digitalWrite(10, LOW);} //turn stereo off
Next, i took a set of two ultra-bright blue LED's on a circuit board, and hooked then up to pin 13. I gave them part of a delay on the code to allow the person to see them. Next, I hooked up a stereo on a power switch tail. I have an old stereo that can be set to play the radio as soon as it is given power. The power switch tail is essentially an enclosed relay. it is available on line at http://www.powerswitchtail.com/Pages/default.aspx ($24.99) or on jameco ($29.99). If you use Arduino 1.0 software, you might have to change your programmer. The default programmer for Arduino 1.0 didn't work for me. I changed the programmer to parallel programmer, (tools>programmer> parallel programmer) and it worked fine.
That's it just turn off the lights, have someone walk in, and enjoy the look on their face.
Thanks for looking.
If you find any bugs or figure out any bugs it has, let me know.