Introduction: Arduino Time-and-Sensor-Based Android Music Player

Imagine your music player that play for you, a player that sense the ambient LIGHT, TEMPERATURE and TIME that affects the mood of a person, and pick a song categorize as MOODs. Because I don't have a sensor that can translate human emotion or thinking to numerical data, I assume that an environment surrounding humans can affect our emotion and which is readable as an analog data using sensors, and because time can easily affect the environment basic traits like light intensity and temperature, I found it as a good solutions for this project. The sensors I used are not enough to consider the exact environment situation, we can still add humidity and sound.

How it work

1. Download and open my Android application(ATSA_Music_Player) and set the wake-lock to maximum.

2. Pick songs according to your choice as BLUE,GREEN,RED.This is how I categorize emotion,as colors. This colors may categorize as genre, blue for instrumentals, blues, acoustics etc. green for pop, acoustic rock,electro etc., and for red, you can choose hard rock, metals, rap, etc. Don't forget to save.

3. Connect your Android phone Bluetooth to your Arduino and tap start button. You can pause, resume and hit next to manually control the songs, but the app can update the data reading and change the MOOD and randomly pick and play a song for YOU.

What you will need for this project

1. Android Phone(2.3 and above)

(I guess you already have one )

2. My APP, Arduino Time-and-Sensor-Based Android Music Player

(not yet available in playstore but can be downloaded here)

3. Arduino-25$

4. Bluetooth Module(HC-05)-$15

5. LDR(light-dependent resistor) sensor-$0.2

6. LM35 temperature sensor-$1.2

7. Bread board-$5

8. male-male connecting wires- $6

9. USB cable A-B -$3

For Software

1.Arduino IDE


You will need your Arduino, bluetooth module, sensors, breadboard and wires here

1. First, prepare the materials.

2. Know your pins. I'm using HC-05 bluetooth module in this prototype, any bluetooth module is compatible. You may refer to this page.

3. After getting the right pins, power up the module by connecting 3.3V and ground to module's Vcc pin and ground pin respectively. Your Android phone only receives data, therefore we only need Tx pin of Arduino to Rx pin of module. Please follow the right voltage divider or you may see the magic white smoke appear ones. I use 220 ohms and 1k ohms.

4. After setting up the module, lets start with the sensors. You also need to learn the name of each pins for proper connection for LM35. Please refer to this helpful instructables.

5.Connect the signal pin of LM35 to A0 of Arduino. For LDR(light-dependent resistor), you don't need to worry about the pins, Drag 1k ohm resistor(brown black red) to ground and LDR one pin to the 1k ohm resistor, same pin of LDR where 1k ohm resistor connected,connect this node to A1 of Arduino and the other pin of LDR will be 5V. The circuit is on the picture.

6. And now you're done. Plug the USB cable for programming the Arduino.

Step 2: Software 1

Here is how I map the data to transmit to arduino. This will depend where you live, so I should probably show how I made it.

1. For temperature, I use room temperature as base value (24*C), as it go low, the software decides as cold, maybe it is raining or snowing in your country. There is a lot of consideration here, it may vary from where to how you install the sensor.

2. For light, I just map the analog reading to 0-100%. I conduct data gathering with respect to time(morning,mid-day,evening) to know the proper data to use. You can adjust those variables.

Light Scaling Temp Scaling

HIGH: 80%-100% >=31'C

MED: 40%-79% <=30'C & >=24'C(room temperature)

LOW: 0%-39% <=23'C

3. Uncomment(remove //) the lines to debug the data gathered by the Arduino. Use Serial Monitor.

//Serial.print("TEMPRATURE = ");



//Serial.print("LIGHT = ");



4. Upload, after data gathering, remove the entire line above or comment it again.

NOTE: Arduino send 3 data.1- blue 2-green 3-red in HEX format.

Step 3: SOFTWARE 2

For the Android application, this app is made from App Inventor 2 of MIT and Adobe Photoshop CS6 and some Google images. The algorithm is a linearly logical and easy but it took me 3 days to finish. A lot of trial and error in picking the right tool like activity starter, sound player and video player. But for picking the songs, I use activity starter and return file URI to a variable and tag to a database. In the main screen, after the connection process, by tapping the START button, it will randomly play the songs in a category database and by tapping PAUSE,PLAY and NEXT, you can manually control the app. But for our pleasure, like I said, it will play for you, update the MOOD color and playlist after every song completed.

1. Download my App and Install.

2. Tap ADD SONGS button, another screen will appear and serves as playlist editor, tap Pick Songs to pick and Save to Xcolor to save.There is also a local and global clear if you want to clear the data in database. Every pick of song should be saved to increment the number or songs in your playlist.

3. Go back to main screen and connect to your bluetooth module. Make sure you already paired your module to your phone. My module named "daniel"


To add songs easily in color playlist, make folders according to color names with your songs inside. :)

Step 4: Additional Notes and Enjoy!!!

Additional Notes

1. You can not tap START button unless you are connected to a Bluetooth device.

2. The App will hang and cause run-time error if no data is received.

3. I haven't fix the bug where no songs on playlists and then you start playing the player. The app generates a random operation from 1 to maximum number of songs stored.

4. Set your phone wake lock to maximum or else your music will stop playing. There is no function in app inventor that you can play song even if the screen is off.

6. Enjoy!!!

Want more?

Android Tablet to Android PC Desktop

Multi-Moded Hack-Cam using Arduino

Gadget Hacking and Accessories Contest

Participated in the
Gadget Hacking and Accessories Contest

Sensors Contest

Participated in the
Sensors Contest