ECE 110/120 Honors Lab Section : TA Project: Playing Music with an Arduino

Description

This package is for students looking to play music using an arduino. Because music files are larger than most arduinos can store and connecting speakers to an arduino can be a relatively difficult process, this package uses a .jar java program running on a computer to play music. The arduino uses Serial.print() statements to sent information to the Java program using the COM ports (for windows), but is also set up for other operating systems. 

Setup

This program relies on some specific expectations in order to work properly. Currently the code is set up to change the audio volume and select a song based on the arduino's decision. Song files must be stored in a director called 'songFiles' in the C:\songFiles directory. Songs must be stored as wave files and in the songFiles directory a songNames.txt file must exist that includes the song name and the duration of the song in seconds. Examples are provided in the download. Please read the read me files for more information. 

Using the Program

Once it has been set up properly the program must be initiated.

On Windows

Using the cd (change directory) function, navigate to the folder where the jar file is saved. In this case, the file was stored in C:\Users\atmarsh\Documents\NetBeansProjects\SerialTest\dist 

Then type 

java -jar "fileName.jar"

Replace 'fileName' with the name of the file.

 

The output of the code will be as follows:

First line: current audio level

 0.5000076

Then all of the lines from the songNames.txt file.

     Afterlife.wav 195
     Awoken.wav 282
     ...
     TheRhyme.wav 245

Then there is some library ouput.

Then

     true
     Started

some standard output to notify you that the code is working.

     8 0.50

output from the arduino (song index, volume)

     0.5 8

arduino output reversed

     Dreamwalker.wav

file name for selected song

     Continuing

'Continuing' is printed when the song delay is over (ie. the duration of the song declared in songNames.txt has elapsed. Can be set to 0, but can result in songs being played over each other).

The last 4 lines are repeated for each song that is played.

Resources

Zip file download: https://drive.google.com/file/d/0Bwj1vqwuk3cKVl9SWlBtNVFWUTg/view?usp=sharing

Attachments:

Code Output.PNG (image/png)
Navigation.PNG (image/png)