Play Music fom MusicShield

I want to play different music files from the Music Shield on an ArduinoUno. I used the ASA Example ASA1_simple and it works pretty good. But now I want to start the songs afte a signal from one of the INPUT ports. Which ports can I use and how do I have t adjust the ASA1_simple sketch? Did anyone a similar project and could help?

Hi and welcome to the forum,

Unfortunately I have no experience with music shields.

There are quite a lot of arduino shields available for all kinds of purposes including music. Arduino is open source, it's quite popular, and tons of people develop shields. Giving as much info as you can will there for make it easier to answer your question.

An url where others can find the shield makes it easier to answer your question for example. You can also post the code using the #-button (message-menu) as well.

To answer your question, you can adapt an example sketch. Your shield probably doesn't use all IO-pins, it should be possible to use unused pins for other functions.

Thank you for the information. The shield i am using is the following:

and the sketch I use to play a song is:


  • Beispiel: simple
  • Beschreibung: Dieses Beispiel zeigt die Ansteuerung der SD-Karte und
  • des MP3-Decoders.
  • Dabei wird die Datei “001.mp3” von der SD-Karte gelesen
  • und über den MP3-Decoder ausgegeben.
    #include <SD.h>
    #include <SPI.h>
    #include <AudioShield.h>


  • Funktionen
    void setup() {
    //Einrichten der LEDs
    pinMode(LED_BLUE, OUTPUT);
    pinMode(LED_RED, OUTPUT);

//beide LEDs ausschalten

//SD-Karte initialisieren
//SD_CS als parameter übergeben, da hier ChipSelect anders belegt
if( SD.begin( SD_CS ) == false )
// Programm beenden, da keine SD-Karte vorhanden

//MP3-Decoder initialisieren

void loop()
//Puffer für MP3-Decoder anlegen
//MP3-Decoder erwartet Daten immer in 32 Byte Blöcken
unsigned char buffer[32];

//Datei öffnen und abspielen
if( File SoundFile = “001.mp3”, FILE_READ ) )
//Blaue LED während dem Abspielen leuchten lassen

//Verstärker einschalten

//Datei bis zum Ende abspielen
while( SoundFile.available() )
//Puffer mit Daten aus der Datei füllen buffer, sizeof(buffer) );
//Daten aus Puffer an MP3-Decoder senden
VS1011.Send32( buffer );
//Internen Datenpuffer vom MP3-Decoder mit Nullen füllen
//damit sicher alles im Puffer abgespielt wird und Puffer leer ist
//MP3-Decoder besitzt 2048 Byte großen Datenpuffer

//Verstärker deaktivieren

//Blaue LED nach dem Abspielen ausschalten

//Datei schliessen

//Datei nicht gefunden
//Rote LED für 2s leuchten lassen
delay( 2000 );

Maybe this helps to find a solution to my problem.


What are these doing? Where are they defined?

But now I want to start the songs afte a signal from one of the INPUT ports.

So, what’s the problem? The code is commented well enough so that you should be able to see what is actually playing the track (that is everything in loop()).


Simpson_Jr: You can also post the code using the #-button (message-menu) as well.

Forget that bit did we?