It's been a long day and when you get home, you just want to relax and put on some music. Now, you can do just that, hands free! With the Motion Activated Music Player detailed below, you can have your Photon play customizable tunes and jingles when you enter a room.
One photon will be connected to a PIR (passive infrared) sensor that detects motion through change in temperature. The LED on the photon and another LED inserted into the breadboard will visually signal when the sensor is set off. When motion is detected, a signal will be sent to a second photon.
Also, each time motion is detected, a count will be sent to ThingSpeak, where it will graph the counts against time.
The second photon will receive the signal and tell the speaker to play a tune. The tune can be customized within the code in Particle Build by varying the frequencies and time delays between notes.
Have fun with creating your own tunes, or trying to recreate your favorite songs. Mix it up around holidays and play some patriotic tunes at 4th of July, scary sounds at Halloween, or carols at Christmas. Friends and family are sure to be delighted, too!Uses
This project can be used to play music on command, welcome guests into your home, or as a simple alarm system. By just a few changes to the code, you can set the photon to play a number of tones you want at the frequencies, duration, and spacing desired. Making Improvements
The first melody used is from an example code on the Particle website. This code can be seen below under "Photon 2: Speaker Code". We then altered this code so that the photon would play "Jingle Bells" when motion was detected. This was accomplished by adding more tones, changing the timing between notes to match the beat, and experimenting with various frequencies to try and match the song. The photon does not quite hit the notes as well as musical instruments and the $2 speaker doesn't help much, but the photon does pretty good. If I'm being totally honest, having a tone deaf coder is most likely the problem.
This project can also be improved by upgrading equipment. One option is using the DFPlayer - A Mini MP3 Player For Arduino. This chip allows you to insert a micro SD card loaded with your favorite music and will only cost about $10 plus shipping. An example of this can be seen on the Particle Community page. Another option for upgrading the equipment is using an Arduino Uno along with an Adafruit Wave Shield. This will cost over $40 plus the cost of shipping, but it will allow for easier connection to better speakers. The Adafruit Wave Shield has much more functionality for those trying to go above and beyond on their project.