Motion Feedback MP3 Player
Intro: Motion Feedback MP3 Player
Concept: Create a feedback loop between a motion sensor and MP3 player volume
I wanted to create a positive feedback system to encourage more activity during a workout. What I came up with is an MP3 player that is controlled by continuous activity. After working with it and discussing the project with friends, I believe this concept could be implemented many different ways and maybe even directly embedded in a media player. Someone even brought up that they change the volume on their iPod to hear the songs as they workout or run harder just to hear the song better. Yeah Power Song!
My proof of concept uses a SparkFun MP3 Trigger, Parallax PIR Motion Sensor, and an ioBridge IO-204 Controller. When motion is detected by the PIR sensor, the IO-204 sends serial commands to the MP3 player to raise or lower the volume. An added benefit to using the IO-204 as the controller is that I have the ability to data log my activity when it's net-connected.
STEP 1: Gather Up Components
Time to gather up your system components:
SparkFun MP3 Trigger
Parallax PIR Sensor
ioBridge IO-204 Controller
Project Enclosure
Speakers
Micro SD Card with Favorite Songs
Hookup Wire
STEP 2: Modify Enclosure
After finishing up my cup of General Foods French Vanilla Cafe, I noticed that the container would be a perfect project enclosure - kind of like a taller Altiods tin so many people use.
I drilled four holes in the bottom and placed screws to act as standoffs for the MP3 Trigger. I also drilled out a larger hole on the font side to support the motion sensor. On the back, I made holes for the speaker connection and hookup wires to the IO-204.
STEP 3: Setup the SparkFun MP3 Trigger
Program 9600 Baud Firmware (optional)
I wanted the MP3 Trigger to support 9600 baud for more controller flexiblity, so a friend reprogrammed the MP3 Trigger with new firmware. He found the firmware and instructions on the creator's website. To re-burn the firmware you will need a Cypress MiniProg.
Load Songs onto Micro SD Card
Copy songs over to a microSD card. The card must be formatted using FAT16. The songs support a constant bit-rate sampling up to 192kpbs.
Make Connections
The MP3 has three pins that are required to be connected to the IO-204 - GND, USBVCC, and RX. There is also a switch that should have "USB" selected. This will allow the MP3 trigger board to powered by the USBVCC pin. Connect the corresponding pins to the IO-204.
Control Playback and Volume
The serial protocol is simple. Send the serial string "O" to start / stop the MP3 player. Send "v%01" to set the volume to the maximum. To lower the volume send serial strings of "v%XX" where XX is a number between 01 and 40 - "01" is the loudest and "40" is really low.
STEP 4: Setup the Parallax PIR Motion Sensor
The PIR sensor has two modes: High and Low. When the sensor is placed in "high" mode, the sensor will go high and stay high as motion is detected. In "Low" mode, the sensor pulses when motion is detected. (Also used this guy on the Half-Hour Halloween Hack)
I used the High mode to interface with a digital input on the IO-204. Connect the "+" and "-" to the +5v and GND of the IO-204.
Motion Sensor Notes
The PIR sensor can detect motion up to 20 feet away. I found that the sensor works best after a minute of no activity right after the sensor receives power. Parallax mentions this is the sensor calibration phase.
STEP 5: Setup the IoBridge IO-204 Controller
The IO-204 acts as the controller taking input from the PIR sensor and controlling the MP3 Trigger. I used two different channels in my demo, but afterwards I figured out how to use one channel.
Make Connections
Each channel has Serial Out, Analog Input, and Digital Input. The PIR sensor connects to the Digital Input (pin 2) and the MP3 Trigger's receiver connects to the digital output (pin 3) of any open channel.
Create Onboard Rules
The IO-204 is programmed via a web interface. You want to create "Onboard Rules". They are "programming-lite" or "logical triggers - if then", if you will. Once the rules are programmed, they reside on the IO-204 with or without a network connection. That feature came out in one of the recent firmware revs, so make sure you're up to date. The IO-204 has a dual red/green LED to indicate it's network status. RED is offline and GREEN is online.
I wanted the IO-204 to change the volume of the MP3 track as motion is detected. As more motion is detected, the volume should increase to a maximum level by stepping through volume levels. I decided on 4 volume levels as a first attempt. When the MP3 player starts a track the volume is low. I also decided to check the motion status every two seconds. If there is continuous motion, over 8 seconds the MP3 player will reach the highest volume level. The volume will step down in volume as activity decreases.
When you have created your states, make sure you click "Sync Rules" to transfer your rules to the IO-204 module.
Log Your Activity
When the IO-204 is online, the module can push data to the ioBridge servers to be data logged. I created a digital input log (for both the high and low states). The data is accessible via an API. With a simple PHP script my friend was kind enough to assist with, I added up all of the the high states to see how much activity the system logged.
STEP 6: Stay Healthy
After some tweaks and tuning, I got the volume states to where I wanted them. Overall I am very happy how the proof of concept turned out. In the process, I also found another use - motion detector, IO-204 sending email when motion is detected or play a sound as an alarm that is triggered by motion. Or if I slack off too much, perhaps I will have it play some "encouraging words" from R.Lee Ermy (the Full Metal Jacket drill sergeant.).
9 Comments
phillsmit3 10 years ago
I would like a mp3 shield, trigger or something similar.
I would like to send a 12v signal to the MP3 player. when the MP3 player receives the 12v power I would like it to automatically start playing an MP3 file. then when the 12v is removed the mp3 player stops playing. then when the 12v is supplied again it starts playing the same mp3 file.
I know i can do this quite simply with an arduino but can i do this without it?
polymythic 10 years ago
From the product description
"The board has 18 external trigger pins that will directly trigger pre-selected MP3 tracks, and a full-duplex serial control port that provides full transport control, remote triggering for up to 256 tracks". If possible, couldn't you just leave it powered? Then just take your 12v signal and regulate it to 5v:
...and attach it to the trigger pin corresponding to the track you want. Same effect, but the .mp3 trigger is powered all the time. Otherwise, (not sure this will work) would be for your 12v signal to feed into the input for the .mp3 to turn it on, and then in parallel regulate the same source to 5v as described above, and hook that onto the trigger pin. There may be latency as the board "boots" and then reads the pin, or it may not like having its input pin triggered as its booting. Perhaps doesn't trigger until an edge change has happened.
phillsmit3 10 years ago
Excellent I was hoping it might work. I would leave it powered all the time and use a push button to trigger the mp3 file. would this idea work with any mp3 shield. or is the trigger different in someway? thank you for your help.
olegka 14 years ago
iobridge 14 years ago
inchman 14 years ago
polymythic 14 years ago
odin84gk 14 years ago
polymythic 14 years ago