Greetings. Christmas is coming and at work we often make something funny/interesting for this period of the year. About last year you can read in a previous post here, although it wasn’t all that interesting.
This year we decided to make some kind of an interactive thing and use the arduinos that we had laying around. So the idea was like this: To make a box that had a camera and 2 push-buttons. One button would play some kinda Christmas music, another button would take a picture through the camera and upload it to our website, where we could display them all.
The building process started from making a working concept with arduinos. First was the musical arduino, it was programmed to play something when the button is pressed and the green LED would blink to the beat, after it’s done playing, that green LED lights up for some seconds to indicate that the arduino is sleeping and is taking no input – this is to prevent spam.
Last year I made it play one of two Christmas melodies when UNO was hooked to our door, this year I found a really cool RTTTL class that could interpret the string notes and play it on an arduino. This means that there is a lot more melodies you can make it play! The old code can be found here, new code can be found here.
When that one was done, I started working on the second arduino that would snap a picture. Well it doesn’t work exactly like that… The process is like this: when button is pressed, arduino sends a keystroke to the computer, the computer has WinHotKey installed which triggers an action on that keystroke, to run a Python script which snaps a picture through the webcam and sends it to us. We then get an email about the action and then it gets displayed on our website, individual photos can be shared on Facebook, and the latest taken photo is displayed on the digital signage TV under which this project hangs, connected to a computer that is controlling digital signage TVs :P
With arduino Leonardo, Micro, or Due you can make them appear as an actual HID device. Unfortunately for me though, I only had a Nano board which is not capable of that. Solution was to use a USB keyboard controller. So I found a broken keyboard that was laying around, ripped it open and traced what contacts produced some kind of a keystroke. In my case pins 25 and 5 sent a letter C, and that was enough to make the computer interpret it as a hotkey and run my script.
Code for this part is in my projects folder.
The keyboard controller sends a keystroke whenever the contacts are connected. It appears though, that when you program the pins on an arduino to be in output mode, they connect internally and stay that way, so the keys would be sent non-stop… I had to put the pins in output mode, delay for 100ms and put the pins into input mode again. 100ms is enough to trigger a keystroke just once.
Making a box
Ok, so the hard part was done. Now everything needs to be fitted somewhere. For this I used a flat cardboard box laying around from a network switch. Probably a sturdy plastic or metal box would of been better, but meh.
It was perfect, but the front and back of it was a bit too thin, I had to reinforce them with something and transparent thermoplastic from my previous project was a perfect fit for that.
Before drilling anything I spray painted an awesome face on the box and let it dry while I do other things.
While it was drying, I marked down where all of the components would go and made some holes.
When paint was dry, I put transparent thermoplastic into it and started assembling components together.
LED lights were there to light up the faces, and I used a fancy flip switch to turn them on, and everything was connected to a USB hub, which I also had laying around from my previous project, so that I only had one USB cable going out.
Now that it’s finished, it all looks like this:
There are some things I didn’t think about, one being some kind of an audio signal when the picture would be taken, or simply a different LED would of been ok. A more sturdy case would of been cool too.
The rest of our office was decorated as last year, nothing fancy :P