Hey everyone. Time to start writing your own tunes for your Percussion boards! First thing's first, you're going to need software generate and send music down to your Arduino. We're going to use a similar program to Arduino called Processing. What's the difference between these two programs? Arduino IDE is used to generate code that runs on your Arduino boards directly. Processing is used to generate programs that run on your computer. The Arduino programs are much leaner than Processing programs (in terms of what they can do), and you'll typically run into hardware constraints on the Arduino before Processing.
In a nutshell, we're going to use Processing to read a CSV text file (which you can create in Excel), then we're going to read the text file line-by-line with some Processing code and send the music down to the Arduino via USB. The Arduino is going to interpret each message received on USB to fire the solenoids. Sound simple enough? Lets get started.
Setup your Arduino with the Player code
Next, connect your Arduino to your computer and open the Arduino IDE.
Once you're in Arduino, click 'File->Save' and save the sketch as 'Robot_Orchestra_Instrument'.
Then copy and paste the code below into your Arduino sketch and save again.
Finally, upload the code to your Arduino and it's ready to roll!
Open your web browser and go to https://processing.org/download/?processing
Click on your operating system of choice to download (rather go with the 32-bit version), unpack the download, then run the Processing app.
Music Player in Processing
Download this Processing player here, unzip it and run 'RobotOrchestra_Player.pde'. This should open in Processing.
Then, in the same folder as the 'RobotOrchestra_Player.pde' file, you should find a folder called 'data'. Open this file to find your song called 'song.csv'. This is your Guitar-Hero-style song that you're going to modify to wrote your own music. Before we start writing anything lets test that everything works.
This is the tricky part. Depending on what other devices are plugged into your computer, your Arduino might show up on a different serial port. Usually it will show up on 'COM1' but this could be different.
Click the 'Run' button on the Processing IDE to see if COM1 works.
If everything is ok, you should see the 8 LEDs on your Percussion board start flickering. If it doesn't work, modify the code in your processing sketch to use COM2 instead COM1. You can keep trying different COM ports until this works, or you can send us a screenshot and we'll try help you out.
If you've gotten this far, you're ready to start making some music! Open the 'song.csv' in Excel and you should see something like this:
This is your Guitar-Hero-Style music score :)
You can modify the music by changing the zero's and one's, and adding/removing extra rows. Just remember to keep your rows in multiples of 8 to make sure it sounds like actual music.
You can also adjust the speed that your music plays by adjusting the 'bpm' variable in your processing code.
Most music ranges between 70-165BPM, so experiment and see what you can come up with. If you run into any problems, don't hesitate to post your questions. Good luck and have fun!