Meet’s Epic Welcome Music Project
The project I have been working on of late at BlueStamp Engineering is an mp3 player of sorts that starts to play music when you open a door. It’s interesting to work on because it’s not too difficult but it does provide a challenge. I experimented with different sensors and ways to write my code but with the help of Bill Porter (http://www.billporter.info/) and sparkfun’s mp3 shield, the coding went a lot smoother.
Credit to http://dynamicboost.wordpress.com/2012/03/05/door-welcome-music/ for help with finding the materials and the inspiration.
What I wanted the project to do was play music when I opened the door but I also wanted to be able to pause/stop the whole thing whenever I wished to. When you open the door, music will play and you can switch the music by a press of a button. When you close the door, the last song that was playing will play out and then the music stops. I added a switch that stops whatever music is playing and no music will play if the door is opened until the switch is turned back on.
Here are the materials I used:
Final Bill of Materials for Epic Welcome Music project
- 2 speakers
- 1 hall effect sensor (or reed switch)
- A push button
- 2 LEDs to test
- Sparkfun MP3 shield
- arduino uno
- A 100k or 10k resistor
- 2 10k resistors
- A 3-5 of 1k resistors (for the LEDs); you might not need all of them but keeping a few of these handy will help you out later on
- Alnico Magnets (most any other magnet will do but if your hall effect sensor doesn’t come with one, you will need this)
I started off by soldering the Sparkfun Mp3 shield and placing it onto the Arduino Uno. Once I had that done, I placed a wire leading from the 5v on the arduino to power the reed switch that I used. When the reed switch closes the circuit, power travels through to the other wire which leads to a pull-down resistor and a wire leading to an analog pin for input. Using the analog pin wasn’t necessary but the sparkfun mp3 shield has some pins you can’t use for certain purposes so I just avoided them. So once I attached a 100k resistor leading to ground (the green wire in the image) and a wire to sense the voltage (the orange wire to the left), I was done with the hall effect sensor. To test it and make sure it worked, I coded in my arduino to send voltage through a wire (the yellow one to the right) and light up an LED (the green one) when the reed switch sensed a magnet. The yellow wire leads to a 1k resistor which leads to the LED which is soldered to ground. When working with LEDs, I had to make sure they were in the right direction otherwise they wouldn’t work.
The next step was adding the switch. This allows me to turn the music off whenever I please. I used a rocker switch and I soldered wires on to it. I hooked one wire up to power by soldering a connection underneath the protoboard to the yellow wire on the left that also provides power to the reed switch. I originally did this on a breadboard to make sure everything worked first and it helped give me a better idea on how the power should be connected. The other wire on the switch I soldered to a wire leading to an analog pin on the arduino and a 10k resistor leading to ground. I also soldered a wire leading to 1k resistor leading to an LED (the red one in the image) on the other wire of the switch.
I soldered wires to the button as well and placed one wire leading to ground. The other I had go to a 10k resistor which led to ground and I also soldered a wire on there which lead to another analog pin.
Here is an image of the bottom of the protoboard; it shows a bit more of the connections and how I did them:
Source Code and Schematic that is helpful for my project (ZIP file): EpicWelcomeMusic
To see it in action check out this video:
However, before it was finished, I had to reach some milestones along the way: