Arduino Powered Haunted Mansion Singing Busts
by TheNewHobbyist in Circuits > Arduino
97403 Views, 248 Favorites, 0 Comments
Arduino Powered Haunted Mansion Singing Busts
After I started learning to program my Ardunio this evolved into a photocell actuated video "on demand" Halloween display. I used an example I found on Arkadian.eu to control a Dell Mini 9 netbook running AutoHotKey. When the photocell switch is tripped the Arduino sends a serial message to the Dell laptop which is converted to a keystroke by AAC Keys which in turn triggers the below AutoHotKey Script and finally plays back using VLC. The "AAC Keys" could probably be replaced by setting up your Arduino as a USB HID but at the time this was all a foreign language to me.
So, lets get to the build!
Hardware: Don't Lose Your Head Over This.
In addition to the switch my hardware list included:
- 4 styrofoam heads (found on eBay)
- Dell Mini 9 netbook for video playback
- A 800x600 VGA projector
- Old Karaoke machine for audio playback
- Arduino UNO
- Radioshack project box to keep the Arduino dry and happy
- And the previously mentioned photocell and 12v wall wart
Software: Lets Go to the Head of the Class
As I said in the introduction I primarily used four pieces of software to run this project (all of which are free) they are:
- My programmed Arduino UNO
- AutoHotKey (Windows macro program)
- AAC Keys (Turns serial input into keystrokes)
- VLC (video playback)
Here's the code for the AutoHotKey script:
a::
Run, c:\Program Files\VideoLAN\VLC\vlc.exe -I rc "VIDEO_FILE_NAME"
Sleep, 61000 ; Pause for video to play, prevents triggering multiple times.
Process, close, vlc.exe ; Kill vlc and make sure it stays dead.
Return
As you can see it's pretty simple. When the "a" key is pressed VLC is launched with arguments to hide everything but the video itself. The script waits for the length of the video (61 seconds) then it closes VLC to reset and run again.
The Arduino sketch isn't much more complicated it waits until the photocell is triggered, then sends the "a" key to the computer over USB (which AAC Keys turns into a keystroke) and waits for 61 seconds before it can be triggered again.
/*
Serial Keyboard
Used to send keystrokes to a Windows PC running AACKeys.exe which
turns serial data into keystrokes. Best used in conjunction with
AutoHotKey.
Examples and idea based on the work of http://www.arkadian.eu and
information from http://wwww.ladyada.net
TheNewHobbyist 2010 <http://www.thenewhobbyist.com>
*/
// Initialize variables
const int buttonPin = 2;
const int ledPin = 13;
int buttonState = 0;
// Set inpout/output and start serial
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
Serial.begin(9600);
}
// Main code loop
void loop(){
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
Serial.print("a"); // send key to PC to start video playback
delay(61000); // ignore input until video ends
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}