I got the VMUSIC2 firmware updated and I can get it to respond to commands. However, quite often a command is received as being a "bad command" and I have to send it 3 times before it will finally be accepted.
Any ideas what might cause this? One issue is that since I am using software serial to communicate, the voltage levels are 5V and I think think the VMUSIC2 is expecting 3.3V levels. If this is true I can just use a logic level converter (I got some from sparkfun).
Another thing I noticed is that VPF commands trigger the audio to play almost instantly (which is great) but once the file is finished playing I have to wait for about 5-7 seconds before I make another command. If I don't then I get the condition of having to re-send commands three times in a row.
Any other ideas?
thanks,
Danjel
This is the code I am using:
#include <avr/interrupt.h>
#include <SoftwareSerial.h>
#define VMUSIC_CTS 5 //to VMUSIC CTS pin 6 (or ground!)
#define VMUSIC_RX 2 //to VMUSIC TXD pin 5
#define VMUSIC_TX 3 //to VMUSIC RXD pin 4
#define ledPin 13
// set up a new serial port
SoftwareSerial mySerial = SoftwareSerial(VMUSIC_RX, VMUSIC_TX); //(RXpin, TXpin)
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
// define pin modes for tx, rx, led pins:
pinMode(VMUSIC_CTS, OUTPUT);
pinMode(VMUSIC_RX, INPUT);
pinMode(VMUSIC_TX, OUTPUT);
pinMode(ledPin, OUTPUT); // declare LED as output
digitalWrite(ledPin, LOW);
// set the data rate for the SoftwareSerial port:
mySerial.begin(9600);
//This will allow softwareSerial to process incoming automatically:
attachInterrupt(0, readSoftwareSerial, LOW);
//Tells VMUSIC that hardware is connected:
digitalWrite(VMUSIC_CTS, LOW);
delay(200);
mySerial.print("VSV ");
mySerial.print(0);
}
void loop() {
int serialReceived = 0;
if(Serial.available() > 0){
noInterrupts();
digitalWrite(VMUSIC_CTS, LOW);
}
while(Serial.available() > 0){
char incoming = Serial.read();
mySerial.print(incoming);
serialReceived = 1;
}
if (serialReceived == 1){
mySerial.print(13,BYTE); //carriage-return for VMUSIC2
serialReceived == 0;
}
interrupts(); //re-enable softwareSerial
}
void readSoftwareSerial(){
noInterrupts();
digitalWrite(ledPin, HIGH);
char incoming = mySerial.read();
Serial.print(incoming);
digitalWrite(ledPin, LOW);
interrupts();
}
/* VMUSIC COMMANDS:
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
*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////