Violin key inside chip Violin key inside chip

play-v6

Compiling the program

Building the executable code and programming the Arduino

Choose your compiler

You can compile play-v6 with the Arduino IDE (on any system, but see note below), with Atmel Studio 6 (on Windows) or with any development environment you like, as long as it uses the avr-gcc compiler and the related library (avr-libc):

Note for the Arduino IDE: be sure to use version 1.5.4 or later, especially on OS X, or play-v6 may not compile. There seem to be inconsistencies between versions (the version installed from Ubuntu repository works fine, despite being labeled "1:1.0.5+dfsg2-2"; the maintainers probably packaged the right version of avr-gcc).

Compiling with the Arduino IDE

Open the player folder and double-click the player.ino icon. The project will open in the Arduino IDE, as shown below.

In case double-clicking the icon does not work on your system, launch the Arduino IDE (i.e. the Arduino program) and load the player.ino file from the menu File, Open.

play-v6 project in the Arduino IDE

Click the Verify icon 'verify' icon in the Arduino IDE to compile and check the source code. It should compile smoothly without errors or warnings.

If you see a line saying "Low memory available, stability problems may occur", just ignore it. The Arduino IDE is trying to guess and it guesses wrong.

Lastly, click the Load icon 'load' icon in the Arduino IDE to send the compiled code to the Arduino Uno (I assume you have already setup and checked the serial-USB connection from the PC to the Arduino).

That is all: you are ready to play some music!

Compiling with Atmel Studio 6

Atmel Studio 6 is a free professional development environment from Atmel, the makers of the ATmega328P microcontroller used in the Arduino Uno. It is a good tool, even if a bit slow and memory-hungry, but unfortunately only works under a single, possibly declining system (Windows). I used it to write play-v6.

To open the play-v6 project, go inside the player folder and double-click the player.cproj icon.

Build the project in Debug mode. Using "Debug" makes no difference to the executable, but the correct file will be sent to the Arduino using the procedure descrived below.

You do not need special extensions (e.g. Arduino libraries) but you have to configure the serial connection if you have not already done it. Open the menu Tools->External Tools and add a new one with:

The COM7 in the "Arguments" string is the number of the serial port the Arduino Uno is connected to; change it according to your setup.

External Tools USB connection configuration in Atmel Studio 6

You will have created a new Tools menu entry ("USB programmer COM7" in the image below):

Menu Tools with USB Programmer selected

I got this tip from www.jayconsystems.com/tutorial/atmerpt1/ (step 5A), where you can find other information for using Atmel Studio 6 for Arduino development.

To send the compiled program to the Arduino, be sure to select the play_v6.c file in the editor before using this new menu entry.

You are ready to play some music!

Compiling with avr-gcc (generic)

You can compile play-v6 with any development environment based on avr-gcc, or just from the command line.

Here is the primitive Makefile I am using; it should work for Ubuntu and derived distributions.

You are now ready to play some music!

If I forgot something (i.e. if it does not work on your system) please let me know.

 


  Updated 23/10/16 by Enrico Colombini (erix@erix.it)