Introduction: 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.).  



Stay healthy my friends,
Steve

www.polymythic.com

Comments

author
phillsmit3 made it!(author)2014-05-15

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?

author
polymythic made it!(author)2014-05-15

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:


  • Trigger inputs: 3.3-5V, active low inputs with internal pull-ups

...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.

author
phillsmit3 made it!(author)2014-05-15

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.

author
olegka made it!(author)2010-11-24

очень полезная штуковина спасибо. за инструкцию

author
iobridge made it!(author)2010-05-24

Great project! Good luck wit the contest. Last month we blogged about your project. www.iobridge.net/projects/2010/04/feedback-mp3-player-and-activity-logger/

author
inchman made it!(author)2010-04-18

 This is cool, but how does it fit in with the Humana contest?  Am I missing something?

author
polymythic made it!(author)2010-04-18

The rules indicate that the contest asks people to "Enter an instructable that promotes health..."  This makes being active just a little easier by allowing you to feel the positive effects immediately of your activity.  If you are rewarded for an activity, you are more likely to do it.  :-)

author
odin84gk made it!(author)2010-04-16

From what I understand, PIR sensors detect a change in heat. How does it detect motion if you are standing in one spot? Does this only work if you are within a few feet?

author
polymythic made it!(author)2010-04-16

From the Parallax site it looks for changes in infrared patterns in its 20 foot field.  So if you are standing still, the image is not changing much, hence no movement.  I don't know the details of the sensor, but perhaps it just sums up the total IR content in its "snapshot" and if there is a lot of change, it registers movement.  I doubt it takes IR values for a field and compares changes at each X and Y position.

About This Instructable

20,201views

48favorites

License:

Bio: By sharing ideas there can be a crossroads of polymaths and myths. The origins of facts (found through science) meeting the origins of our beliefs ... More »
More by polymythic:Haptic Feedback device for the Visually Impaired [Project HALO]Motion Feedback MP3 PlayerServ O'Beer with iPhone for the Perfect Pour
Add instructable to: