User Tools

Site Tools


workshop:vmusic2_arduino

VMusic2 player and Arduino

VMusic2 audio player

The VMusic2 audio player is an affordable and simple solution to playback audio in a controlled way. You put MP3 files on an USB flash disk and then issue commands to the player via serial communication. All modules from the Interaction Workshop have updated firmware. If you buy your own, make sure you upgrade the firmware before using it.

Preparing the USB flash drive

The VMusic2 module can be quite picky with the USB flash drive/memory stick. To improve your chances of having a successful setup, follow these recommendations:

  • use a USB memory drive of 1Gb or less
  • make sure it is formatted in FAT16 (use a PC to do this, on OSX it is possible but tricky)
  • name the memory drive/stick only with big capitals, no space or punctuation: something like “UNTITLED” or “MUSAK” works well we found.
  • name files and folders with no whitespace characters, punctuations or weird characters,following the plain 8.3 notation is the safest: myfile01.mp3

Connecting the module

Issuing commands over serial

From Arduino, Serial.println(“command”) doesn't work properly. It is best and safest to split the command and CR (carriage return) over two calls:

Serial.print("V3A"); // send the VMusic2 command
Serial.write(13); // send the CR in raw byte 
VMUSIC COMMANDS:
*** make sure you issue a CR after the command ***

VPF·file       Plays a single file eg: "VPF 1.mp3"
VRF·file       Repeatedly plays a single file
VST            Stops playback
V3A            Plays all MP3 files
VRA            Repeatedly plays all MP3 files
VRR            Repeatedly plays random MP3 files
VSF            Skip forward one track
VSB            Skip back one track
VSD            Skip forward one whole directory
VP             Pause playback
VF             Fast forward 5 seconds
VB             Rewind 5 seconds
VRD·byte       Reads command register
VWR·byte+word  Writes command register
VSV·byte       Sets playback volume

Advanced stuff

The regular Arduino has only one hardware serial port (Pins 0 and 1). The Arduino Mega offers 4 serial ports. Note that with the use of a library (NewSoftSerial, AFSoftSerial, SoftwareSerial), digital pins can be used as software serial port.

#include <NewSoftSerial.h>
 
NewSoftSerial mySerial(2, 3);  // soft serial: RX on pin 2, TX on pin 3
 
void setup()  
{
 
  // define pin modes for RX and TX
  pinMode(2, INPUT);
  pinMode(3, OUTPUT);
 
  Serial.begin(57600);
  Serial.println("Goodnight moon!");
 
  // set the data rate for the NewSoftSerial port
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}
 
void loop()   // run over and over again
{
 
  if (mySerial.available()) {
      Serial.print((char)mySerial.read());
  }
  if (Serial.available()) {
      mySerial.print((char)Serial.read());
  }
}

The module provides a bidirectional serial communication, so you can get playback time and status, list of files, etc. Check the documentation online for exploring these areas.

An example of a bare minimum program to play a sound once, with no interaction:

#include <SoftwareSerial.h>
 
//establishing digital pin 6 and 7 to be the extra serial port
#define VMUSIC_RX 6
#define VMUSIC_TX 7
 
// set up a new serial port
SoftwareSerial mySerial =  SoftwareSerial(VMUSIC_RX, VMUSIC_TX);
 
void setup() {
  Serial.begin(9600);	// opens serial port, sets data rate to 9600 bps
  mySerial.begin(9600); // set the data rate for the SoftwareSerial port
 
  // define pin modes for tx, rx pins:
  pinMode(VMUSIC_RX, INPUT);
  pinMode(VMUSIC_TX, OUTPUT);
 
  Serial.println("Start");  //Sending statusinfo back through the standard serial port
 
   //Sending the command to play a sound through the new serial port   
   mySerial.print("VPF kettle.mp3"); //kettle.mp3 is my soundfile, what is your?
   mySerial.write(13);
}
 
void loop() {
 
}
workshop/vmusic2_arduino.txt · Last modified: 2011/12/08 13:11 by camille