VMusic2 Anleitung

From Digipool-Wiki
Revision as of 12:23, 25 February 2021 by WikiSysop (Talk | contribs) (PlayOneSong)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
VMusic Arduino.jpg


Komponenten

Zum Bau eines programmierbaren MP3-Players benötigen wir:
Der VMusic-MP3-Player wird von der Firma FTDI entwickelt. Bis jetzt gibt es die Versionen VMusic, VMusic2, VMusic3 die sich jedoch in der Nutzung nicht wesentlich unterscheiden. Da es bei älteren Versionen Probleme mit Bugs gab, würde ich immer die jeweils neuste Version empfehlen.


Funktionsprinzip

Die MP3 Dateie werden auf dem USB-Stick gespeichert und können mit dem Sound-Chip des VMusic2-Moduls abgespielt werden. Dieses besitzt eine kleinen Klinkenstecker für Kopfhörer, Boxen, Aktiv-Boxen usw... Das VMusic2 wird von einem Arduino gesteuert. Das Arduino ist ein kleiner Computer, der sich leicht programmieren lässt. Er gibt dem VMusic2-Player einfache Befehle (siehe unten) über eine Serielle Verbindung. Der große Vorteil dieses selbst gebauten MP3-Players ist, dass wir genau programmieren können, was passiert. An das Arduino lassen sich Taster, Schalter uns Sensoren anschließen über die das Abspielen der MP3-Sounds gesteuert wird. Zusätzlich Kann das Arduino Leuchtdioden, Lampen, Motoren oder andere dinge in Kombination mir dem Sound steuern. Ein kleiner Nachteil liegt in leichten Verzögerung von ca. einer Sekunde, die es dauert bis der VMusic-Player reagiert.



Steuerbefehle

VMusic Steuerbefehle

  • "VSV" = VMusic set volume – 0 (loud) and 254 (mute)
  • "VPF" = VMusic Play File
  • "VRF" = VMusic repeatedly plays a single file
  • "VST" = VMusic stop
  • "V3A" = VMusic plays all MP3 files
  • "VRA" = VMusic repeatedly plays all MP3 files
  • "VRR" = VMusic repeatedly plays random MP3 files
  • "VSF" = VMusic skip forward one track
  • "VSB" = VMusic skip back one track
  • "VSD" = VMusic skip forward on whole directory
  • "VP" = VMusic Pause playback
  • "VF" = VMusic fast forward 5 seconds
  • "VB" = VMusic rewind 5 seconds



Code-Beispiele


PlayOneSong

// PlayOneSong with vMusic2 
// Example by by Olaf Val (www.olafval.de)

#include <SoftwareSerial.h>

// USB-stick max 4 G (hard to buy this days)
// Format the Stick with FAT32
// Name Songs "001.mp3" "002.mp3" . . .

// cut the blue 
// conect the brown to the reen cable
// red cable to 5V
// black cable to GND
#define VMUSIC_RX 14 // yellow cable ti Analog in 0
#define VMUSIC_TX 15 // orange cable ti Analog in 1


// 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

  // define pin modes for tx, rx, led pins:
  pinMode(VMUSIC_RX, INPUT);
  pinMode(VMUSIC_TX, OUTPUT);
    
  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  
  mySerial.print("VSV"); // set volume
  mySerial.write((byte)0); // should be between 0 (loud) and 254 (mute)
  mySerial.write((byte)0x0D);
}

void loop() {
  Serial.println("Song_1"); 
  mySerial.print("VPF 001.mp3"); // play song nr one
  mySerial.write((byte)0x0D);
 delay(9000);
}


PlayNextSong

// PlayNextSong with vMusic2 
// Example by by Olaf Val (www.olafval.de)

#include <SoftwareSerial.h>

// USB-stick max 4 G (hard to buy this days)
// Format the Stick with FAT32
// Name Songs "001.mp3" "002.mp3" . . .

// cut the blue 
// conect the brown to the reen cable
// red cable to 5V
// black cable to GND
#define VMUSIC_RX 14 // yellow cable ti Analog in 0
#define VMUSIC_TX 15 // orange cable ti Analog in 1


// set up a new serial port
SoftwareSerial mySerial =  SoftwareSerial(VMUSIC_RX, VMUSIC_TX);

int n = 0; // Song Nummer
int buttonPin = 17; // Button Pin
int b = 0; // Inputval of button


void setup() {

  Serial.begin(9600);	// opens serial port, sets data rate to 9600 bps

  // define pin modes for tx, rx, led pins:
  pinMode(VMUSIC_RX, INPUT);
  pinMode(VMUSIC_TX, OUTPUT);

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);

  mySerial.print("VSV"); // set volume
  mySerial.write((byte)0x00); // should be between 0 (loud) and 254 (mute)
  mySerial.write((byte)0x0D);

  pinMode(buttonPin, INPUT); // setup Button Pin
  digitalWrite(buttonPin, HIGH); // enable PullUpResistor for Button Pin

}

void loop() {

  // wait untill button is pressed
  b = digitalRead(buttonPin);
  while(b == 1){
    // wait untill button is pressed
    b = digitalRead(buttonPin);
  }
  
  if(n == 0) mySerial.print("VPF 001.mp3"); // play song nr one
  if(n == 1) mySerial.print("VPF 002.mp3"); // play song nr one
  if(n == 2) mySerial.print("VPF 003.mp3"); // play song nr one
  if(n == 3) mySerial.print("VPF 004.mp3"); // play song nr one
  
  mySerial.write((byte)0x0D);
  delay(1000);

  n = n + 1;
  if(n > 3) n = 0;
  Serial.print("Song Nr "); 
  Serial.println(n); 
  delay(100);
  
}