Introduction: AdaBox004 Music Player

I used the parts in the AdaBox004 to make a simple music player. It plugs into a USB port and starts playing songs randomly from the micro SD card. It's for my workshop for a no-fuss source of upbeat songs.

Step 1: Parts

Step 2: Make the Music Box

The general instructions are on the AdaFruit site at

Important to pay attention to:

When reading through the AdaBox004 instructions it's easy to overlook links to instruction sites for the components. Be sure to pay attention to the green boxes that have links for the: Adafruit Feather HUZZAH ESP8266 ( Under the "Using the Arduino IDE" section for the board it has links to the drivers you'll need to connect the board and download code from the Arduino IDE, as well as instructions for adding the board as an option to the Arduino IDE.

Likewise pay attention to the link for the Music Maker FeatherWing ( That has instructions for installing the necessary libraries to the Arduino.

I wired the potentiometer exactly as shown ( - but note that I moved the Feather further back on the breadboard to get the USB cable to fit.

The white box comes with the kit. I simply used a hole punch to make holes big enough for the included USB cable to fit through. I had make a small slit with a pocket knife in the folded box so I knew where on each panel to cut.

For the speaker opening, I estimated the center and marked it with a large foreign coin (Costa Rican 100 colones to be exact), then cut the circle with a shop hobby knife. The speaker was line up and I marked where the small bolts should go with a sharp punch.

Step 3: Music Player Code.

I modified example code for the feather player, stripping out code that didn't apply. You can cut-and-paste it into the Arduino IDE then load it onto your Feather.

Note that I had a hard time trying to get the files to be recognized. What I have here works, but you have to adjust the code to change the number of songs that are available. And note that the way I did it will make it difficult to do over 100 songs (000 - 099) because it only selects 2 individual digits. I could have chosen the actual track number, but then would have had to parse it to create the right file name. Maybe in some future iteration.

The file is also available on GitHub at If I make any changes, that's where they'll be.

<p>// AdaBox004_random_songs</p><p>// Specifically for use with the Adafruit Feather, the pins are pre-set here!<br>// modified feather_player example for AdaBox 004 project
// standalone player that plays random songs from playlist
// stripped out unused code
// had trouble getting file name string to work converting String type
// since function call for playing uses char array
// after trying different approaches this is the kludge I came up with
// tracks are named TRACK##.mp3
// I have 60 songs on SD card I"m using (000 - 059)
// would have been smarter to count # of files or find some other way to get file name randomly
// Oh well next time</p><p>// include SPI, MP3 and SD libraries
#include <SPI.h><spi.h>
#include <SD.h><sd.h>
#include <Adafruit_VS1053.h><adafruit_vs1053.h></adafruit_vs1053.h></sd.h></spi.h></p><p>// These are the pins used
#define VS1053_RESET   -1     // VS1053 reset pin (not used!)
// Feather ESP8266 -- using HUZZAH featther
#define VS1053_CS      16     // VS1053 chip select pin (output)
#define VS1053_DCS     15     // VS1053 Data/command select pin (output)
#define CARDCS          2     // Card chip select pin
#define VS1053_DREQ     0     // VS1053 Data request, ideally an Interrupt pin
#define VOLUME_KNOB    A0</p><p>int lastvol = 10;
int loopcounter = 0;
long trackNumber;
String trackString;
char song[13] = {'T','R', 'A', 'C', 'K', '0', '2', '0', '.', 'm', 'p', '3','\0'};</p><p>Adafruit_VS1053_FilePlayer musicPlayer = 
  Adafruit_VS1053_FilePlayer(VS1053_RESET, VS1053_CS, VS1053_DCS, VS1053_DREQ, CARDCS);</p><p>void setup() {
//  Serial.begin(115200); // only needed for trouble shooting
//  while (!Serial) { delay(1); } // Wait for serial port to be opened,
//  Serial.println("\n\nAdafruit VS1053 Feather Test");
  randomSeed(ESP.getCycleCount()); // HUZZAH has only 1 analog pin which is already used
                                   // needed different random seed
                                   // this idea from <a href="">

  musicPlayer.sineTest(0x44, 500);    // Make a tone to indicate VS1053 is working
  SD.begin(CARDCS);</p><p>  // Set volume for left, right channels. lower numbers == louder volume!
  musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);  // DREQ int
}</p><p>void loop() {</p><p>  // check periodically to adjust volume!
  if (loopcounter >= 1000) {
        loopcounter = 0;
        int vol = 0;
        vol = analogRead(VOLUME_KNOB);
        vol /= 10;
        if (abs(vol - lastvol) > 3) {
//          Serial.println(vol);
          lastvol = vol;
          musicPlayer.setVolume(lastvol, lastvol);
      }  </p><p>  // Play a file in the background, REQUIRES interrupts!
  if (! musicPlayer.playingMusic) { 
    trackNumber = random(6); // have to do this one digit at a time; first digit 0-5
    char c = char(trackNumber + 48);  // ASCII 48 is '0'; need to shift value to get right character
    song[6] = c; // replace the tens value in the char array
    trackNumber = random(10); // second digit 0-9
    c= char(trackNumber + 48);
    song[7] = c;   
//    Serial.println(song);

Step 4: Enjoy

Simply plug in to a USB power supply and enjoy your favorite songs.

Volume can be adjusted with the potentiometer inside the box. Otherwise no controls.