The Adafruit VS1053 Headphone FeatherWing is an add-on board designed for the Feather series of development boards by Adafruit. It incorporates the VS1053, a versatile MP3/AAC/WMA MIDI audio codec chip, providing a simple solution for adding audio playback through a standard headphone jack. This component is ideal for creating portable music players, audio notification systems, and for adding sound to embedded projects.
Pin | Description |
---|---|
GND | Ground connection |
3V | 3.3V power supply from the Feather board |
RST | Reset pin for the VS1053 chip |
MISO | Master In Slave Out for SPI communication |
MOSI | Master Out Slave In for SPI communication |
SCK | Serial Clock for SPI communication |
CS | Chip Select for the VS1053 chip |
DCS | Data/Command Select for the VS1053 chip |
DREQ | Data Request, indicates when the VS1053 is ready for data |
#include <SPI.h>
#include <SD.h>
#include <Adafruit_VS1053.h>
// Define the pins used
#define BREAKOUT_RESET -1 // VS1053 reset pin (not used!)
#define BREAKOUT_CS 6 // VS1053 chip select pin (output)
#define BREAKOUT_DCS 10 // VS1053 Data/command select pin (output)
// These are the pins used for the music maker shield
#define SHIELD_RESET -1 // VS1053 reset pin (unused!)
#define SHIELD_CS 7 // VS1053 chip select pin (output)
#define SHIELD_DCS 8 // VS1053 Data/command select pin (output)
// These are common pins between breakout and shield
#define CARDCS 4 // Card chip select pin
// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt
#define DREQ 3 // VS1053 Data request, ideally an Interrupt pin
Adafruit_VS1053_FilePlayer musicPlayer =
// create breakout board object!
Adafruit_VS1053_FilePlayer(BREAKOUT_RESET, BREAKOUT_CS, BREAKOUT_DCS, DREQ, CARDCS);
// create shield-version object!
//Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);
void setup() {
Serial.begin(9600);
Serial.println("Adafruit VS1053 Simple Test");
if (! musicPlayer.begin()) { // initialise the music player
Serial.println(F("Couldn't find VS1053, do you have the right pins defined?"));
while (1);
}
Serial.println(F("VS1053 found"));
if (!SD.begin(CARDCS)) {
Serial.println(F("SD failed, or not present"));
while (1); // don't do anything more
}
// Set volume for left, right channels. lower numbers == louder volume!
musicPlayer.setVolume(20,20);
// Play one file, don't return until complete
Serial.println(F("Playing track 001"));
musicPlayer.playFullFile("/track001.mp3");
// Play another file in the background, REQUIRES interrupts!
Serial.println(F("Playing track 002"));
musicPlayer.startPlayingFile("/track002.mp3");
}
void loop() {
// File is playing in the background
if (musicPlayer.stopped()) {
Serial.println("Done playing music");
while (1) {
delay(10); // we're done! do nothing...
}
}
if (Serial.available()) {
char c = Serial.read();
// if we get a 'p', pause/unpause!
if (c == 'p') {
if (! musicPlayer.paused()) {
Serial.println("Paused");
musicPlayer.pausePlaying(true);
} else {
Serial.println("Resumed");
musicPlayer.pausePlaying(false);
}
}
}
}
Q: Can I play audio files other than MP3? A: Yes, the VS1053 chip supports a variety of audio formats including AAC, WMA, and MIDI.
Q: How do I control the volume?
A: The volume can be controlled programmatically using the setVolume
method in the Adafruit VS1053 library.
Q: Can I use this FeatherWing with other microcontrollers? A: While designed for Feather boards, it can be used with other microcontrollers that support SPI communication, given appropriate voltage levels and pin connections.