People love listening to music while exercising. Music provides the motivation needed for individuals to keep exerting energy and get in shape. So, because people enjoy listening to music while exercising, what if an MP3 player only played an individual's music while they are active? Using music as an incentive to continue exercising would encourage individuals to work harder and remain motivated in order to listen to their music.
This workout shirt utilizes a LilyPad MP3 player and an accelerometer in order to detect whether or not the wearer is moving, and if so, it plays his or her music. The goal of the system is to promote an active lifestyle for wearers. Follow the instructions to create your own workout shirt MP3 player that is powered by exercise!
The price of our system ranges between $60 and $100 based on parts used, the cost of the shirt, etc. It is affordable, easy to understand and create, and will help promote healthiness and physical activity in society!
The Arduino IDE must be downloaded (free at http://arduino.cc/en/main/software) in order to run our code.
Our code can be downloaded here: https://iu.box.com/s/vc81v70ifv4ebw68d7qq
Check out the working system here:
Step 1: Acquire Parts
-LilyPad MP3 player (https://www.sparkfun.com/products/11013)
-LilyPad accelerometer (https://www.sparkfun.com/products/9267)
-RGB rotary encoder (https://www.sparkfun.com/products/10982)
-3.7V Lipo (lithium ion) battery (https://www.sparkfun.com/products/341)
-Micro SD card
-Headphones or speakers
-Conductive thread and a sewing needle (https://www.sparkfun.com/products/10867)
-Alligator clips (for testing the circuitry before sewing)
The following are optional components that can be used to expand the system:
-Rainbow LEDs (for enhanced visualization)
-Vibration board (for adding a physical aspect of the system to the visual aspect of the system)
-Button (for manual calibration)
-On/off switch (for extra control of the system)
-Extra fabric and card stock (for integrating the system with the shirt using an easier, more durable setup)
Step 2: Safety and Preparation
1. Stay safe! While soldering, be sure to wear protective eye-wear and avoid touching the hot soldering iron. Understand the different components of the system and how to make sure they are used properly. For example, the LilyPad MP3 player should not be connected to speakers while plugged into a laptop via USB; it can only be plugged into speakers when the system is being ran on a battery. Otherwise, parts of the device could be damaged and become increasingly hot and dangerous.
2. Acknowledge your abilities. While the setup of the system is easy to understand, the code is somewhat lengthy and jumps around from one function to the next. For inexperienced coders, simply copying the code will suffice, whereas for experienced Arduino programmers, there are several modifications that can be made to the system. Everyone is challenged to make our system even better!
Step 3: System Explanation
The LilyPad also has 5 different I/O pins that can be used with other components on the exterior (T1, T2, T3, T4, T5). However, T4 and T5 disable the serial monitor from being used when they’re active, so we can’t use them. It also has a ground pin, as will as a 3.5-6V power out. It also has a receiver for the 3.7V Lipo battery to be plugged in.
The 3.7V Lipo battery should be plugged in to the LilyPad MP3. The LilyPad has an on/off switch that will use the battery as power when activated. When it is plugged into the computer, the switch should be off, and it will charge the battery.
The accelerometer sends data on 3 different axes (x, y, and z), and it has 5 connections. The + will be the part receiving power. That should be wired (with the conductive thread) to the 3.5-6V-power output on the MP3. The – (ground) connection on the accelerometer should be wired to the GND (ground) connector on the LilyPad MP3.
On the LilyPad MP3, The T1 connection will act as an analog pin (A0), T2 is analog pin A4, and T3 is analog pin A5. The ‘X’ connection on the accelerometer should be wired to T3 (A5), The ‘Y’ pin should be wired to T2 (A4), and the ‘Z’ connector on the accelerometer should be wired to T1 (A0). These will send data from the accelerometer to the LilyPad MP3 so we can tell how the accelerometer is being moved, or more importantly for this project – IF it is moving.
The Micro SD card is placed in a slot on top of the LilyPad MP3 that is specifically designed for the card. As mentioned before, the mp3 files being played should be stored in the root directory of the card. TIP: The rotary encoder will blink red if there is an error with the Micro SD card (either missing, damaged, unreadable, etc.). If you notice red blinking, be sure to focus your attention to the Micro SD card.
Our system uses the accelerometer to sense motion, and it then communicates the detected motion (or lack thereof) to the MP3 player. The MP3 player then runs the corresponding function(s) based on the values it receives from the accelerometer. The RGB rotary encoder is used as a visual that displays different colors (blue or green) based on what function is being executed (between track and volume, which will be further explained shortly).
Step 4: Setting up the Circuitry
In order to account for users of different sizes, as well as different positioning of the accelerometer, our system calibrates in order to provide accurate readings. Using a button, an optional component for the system, the user can manually calibrate. For our system, we ultimately did not use a button but instead set our system to automatically calibrate if the user remained in the same position over a short period of time. If used, the button should also be attached to the system.
LEDs are also optional components of the system. The RGB rotary encoder is a LED itself, but additional LEDs can be used in order to display progress, distance, time elapsed, etc. Any used LEDs should also be connected to the system.
NOTE: As previously mentioned, the LilyPad MP3 has a limited number of pins, so if your desired system includes a button and LEDs, the LilyPad MP3 must be connected to the LilyPad Arduino, which has many extra pins for input/output components.
The pins are as follows:
xpin (of accelerometer) = A5 (T3)
ypin (of accelerometer) = A4 (T2)
zpin (of accelerometer) = A0 (T1)
+ (power of accelerometer) = 3.5-6V pin
- (ground of accelerometer) = GND pin
Step 5: Setting up the Circuitry
Also, whereas the LilyPad Arduino board seen in the image shows the various analog pins, the LilyPad MP3 player uses T1-T5 pins, as previously mentioned. Make sure to match the T1-T5 pins to their corresponding analog pins for the system to work properly.
Lastly, whereas in the diagram, the power is being connected to the + pin, the LilyPad MP3 player does not include a + pin but instead a 3.5-6V pin, which is used to connect the power pin from the accelerometer to the MP3 player.
Step 6: Soldering the RGB Rotary Encoder to the LilyPad MP3
NOTE: Make sure that when soldering, the solder on each pin does not touch any other pin's solder. If any of the pins are connected, the system will not work properly. Be careful!
Step 7: Attaching the 3.7V Battery
Step 8: Programming the LilyPad MP3 and Understanding the Code
The code has several functions that it runs. The main loop checks the values of the x, y, and z axes of the accelerometer, and defines them as current values. It then compares these values to past, stored values. It initially runs a calibrate function, which defines a set value for x, y, and z which will be compared to, and then sets a "calib" boolean to "false," meaning that the calibrate function will not be run again unless the boolean is set to "true" by a different function or condition. Based on set thresholds (which are set to detect motion or a lack of motion) and the stored values (which also account for zero-G, or the values detected by the accelerometer when it is stationary), the loop checks to see whether or not the values meet the required conditions. If the difference between the current and set values is greater than the threshold, then movement is considered to be detected and the music player runs. If not, then the user is considered to be still, and the music player stops the music.
While the "play music" function is being ran (after the system detects that the difference in values is greater than the threshold), the system then performs an automatic calibration check, which is why we do not need a button for our system, by comparing recent values to each other. If the recent values are all less than another set threshold value (which can be the same as the other threshold value), the user is assumed to be stopped in that position, the "calib" boolean is reset to "true," and the calibration function is again executed. After recalibration, which simply tells the system that the current position of the accelerometer is the base position, the initial conditions are checked again to see whether or not the user is active.
During the "play music" function, all of the other MP3 functions are ran accordingly. For example, so long as the user is active, the user can change between the track (changing tracks) and volume (changing volume) functions. The code will also execute the functions that loop through the songs and start/stop the songs as well, based on the user's interaction with the system.
Step 9: Integrating the System with the Shirt
First, the positioning of the MP3 player is important, as the headphone jack should be in a convenient, comfortable location.
Next, the accelerometer must be positioned in a spot that frequently moves during physical activity. Whereas an arm sleeve or shoulder typically moves during any workout process, positioning the accelerometer on the chest, for example, may not account for exercises that require the chest to stay still (bench press, for example).
HINT: Depending on the material of the shirt used, it may be advantageous to sew the components to card stock and then sew the card stock to the shirt, rather than trying to directly sew the components to the shirt. By attempting to directly sew the components to a thin shirt, for example, the conductive thread may be too loose to function properly, for example.
For our system, we used card stock and sewed our LilyPad MP3 player and accelerometer directly onto it. Then, we created a pocket on the inside of the shirt for the card stock to be inserted. We used extraneous fabric to make the pocket and regular, non-conductive thread to bind the pocket to the shirt. We then cut slits into the shit for the rotary encoder, the prongs for the programmer, and the headphone jack to be exposed.
Step 10: The Completed System
Step 11: What You Should See
After uploading the code and turning the system on, the user begins exercising. Pressing the rotary encoder initializes the music, and continued exercise plays the music. The music will continue to play until the user stops exercising, in which case the music will stop as well. If the user then resumes exercising, the music will then start playing again as well.
The rotary encoder has two primary functions: track and volume. While running the track function, the rotary encoder will be blue. While running this function, the rotary encoder can be twisted in either direction to change songs. The rotary encoder can be pressed and held until it turns green, which indicates that the volume function is being ran. While the volume function is running, the user can again twist the rotary encoder in either direction, which will alter the volume of the music. The rotary encoder can be pressed and held again until it is back to blue, and so forth. Note that for all of these procedures to occur, the user must be active. Also, regardless of which function is being ran, by briefly pressing the rotary encoder (rather than holding it until it changes color), the music player will start or stop. Of course, the threshold of activity must also be met, but by pressing the rotary encoder, the music will initialize and be ready to play when the user is active, or it will instantly stop if the music is already playing.
At the end of a song, the MP3 player should automatically skip to the next song (once again, assuming the user is exercising). We decided that rather than a pause function, the starting/stopping of physical activity should act as a start/stop function for the system. In other words, by stopping exercising, the song will stop completely rather than simply pausing, and the song will restart from the beginning when the user resumes exercising. This adds extra incentive for the user to keep exercising so that they can hear the entire song.
Step 12: Troubleshooting and FAQs
Q: Why is there a brief delay between when I start moving and when the music starts playing, as well as when I stop moving and when the music starts playing?
A: Because the code compares current values to set values and recent values in order to detect consistent activity or inactivity, and because the songs must initialize before being played, there is a temporary delay that occurs. There is no need to worry, however, because despite the brief delay, the system still recognizes the starting/stopping of activity and will execute the appropriate function shortly afterwards.
Q: Why is the system detecting motion and playing music, or why is the system not detecting motion and not playing music, when it should actually be doing the opposite?
A: Based on the threshold values defined within the code, the system detects motion (or a lack thereof) and executes the appropriate code (either "play the music" or "stop the music"). The threshold values can be changed within the code, but the values used for our system are very accurate.
Q: Is the shirt washable? Will it break the LilyPad MP3 player or any of the other components?
A: Yes! The system is washable, which is especially good for a shirt being worn during workouts. However, it is recommended to wash the system as little as possible, as more washes increases the likelihood of damage to the system.
Step 13: What Next?
-Multiple LEDs to indicate the user's progress, amount of consecutive time spent exercising, etc.
-A LCD screen to display progress, statistics, etc.
-A visual game that displays a user's progress compared to other users or the user's previous trials
-A music system where a certain amount of exercise gives you a certain number of seconds of music, so you must accumulate seconds by continuously exercising in order to listen to full songs
-A GPS to complement the accelerometer and detect distance traveled to power the music player
-Limit functionality such as the ability to skip tracks or change volume unless certain exercise criteria have been reached
Try them out! Let us know how they go. We are interested in developing our idea and exploring the endless possibilities of our system!