Violin key inside chip Violin key inside chip

play-v6

Playing music

Controlling the player with the buttons or from a computer

Modes of play

play-v6 can be used either standalone with the control buttons, or controlled by a computer via serial line (over the USB connection, as usual with Arduino).

Playing standalone

In standalone mode, play is controlled by the buttons; the USB connection is not needed. Only music stored into the Flash memory, such as the default samples, can be played (to add new music, use the music compiler).

The connections for the three control buttons are shown on the filter page; their primary function is shown here by the symbols:

Control buttons on the breadboard

The central Start/Stop button has a secondary function: autoplay. Keeping the button pressed while resetting the Arduino, only releasing it when the music starts playing, will repeatedly play all of the stored music in sequence, until the same button is pressed again.

Playing via remote control

To remotedly control play-v6 from the USB connection, you need a serial terminal (on Arduino, the serial line is emulated over USB).

A serial terminal is available in the Arduino IDE from the menu Tools->Serial Monitor, but it is quite primitive and awkward to use with play-v6, though it will do for simple tests.

Getting a real serial terminal is a good idea. On Windows I use the excellent free Hercules SETUP utility by HW group; suggestions are welcome for Linux and OS X.

The serial line must be set up for 57600 bps, 8 bits, 1 stop bit, no parity, no handshake, as shown below. Of course you cannot program the Arduino while the serial connection is open, and vice versa.

Hercules SETUP utility by HW group, used as serial terminal

play-v6 serial commands are single characters: just press the corresponding key (if you are using the Arduino Serial Monitor, you will have to press the Send button after each character).

Here are the accepted command keys:

Sending music from the computer to play-v6

Music code produced by the music compiler can be sent to play-v6 while it is not playing.

Just send the music code file from the serial terminal in binary mode. The code file already contains the 'L' command to start the transfer. In case of problems, an error message will be shown on the terminal.

Send dialog of the serial terminal, with .code music file selected

To start playing the new piece of music, use the Space bar or the Start/Stop button as usual.

The loaded music will remain as current music in RAM, even if the USB connection is detached, until the previous or next music is played.

Controlling play-v6 from a computer program

To control play-v6 from a program you write, the program can just send the serial commands listed above. Some feedback is provided:

You can use a timeout (say, 10 ms) to check if a command has been accepted. If not, either you are sending an invalid or ignored command, or the connection is not working.

When getting an error message from the 'L' command (i.e. any answer starting with '*'), wait for a newline character (0x0a) before sending other commands, or just wait until no more characters arrive for at least 10 ms.

There is no serial buffer on play-v6, therefore always wait for an answer (or timeout) before sending another command.

All replies from play-v6 are made of printable characters, but do not forget to open the serial communication in binary mode (all bytes must pass unaltered), or else the 'L' command will not work.

 


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