Skip to content

Instantly share code, notes, and snippets.

@jenschr
Created May 4, 2023 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jenschr/dacf60d2c9d2bd4efee85768cd5eab82 to your computer and use it in GitHub Desktop.
Save jenschr/dacf60d2c9d2bd4efee85768cd5eab82 to your computer and use it in GitHub Desktop.
Simple sketch to make the baldram/ESP_VS1053_Library work with the Adafruit VS1053 breakout
#include <SPI.h>
#include <Wire.h>
#include <VS1053.h>
#include "SampleMp3.h"
// These are the pins used for the breakout example
#define BREAKOUT_RESET 9 // VS1053 reset pin (output)
#define BREAKOUT_CS 10 // VS1053 chip select pin (output)
#define BREAKOUT_DCS 6 // VS1053 Data/command select pin (output)
#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
#define VOLUME 100 // volume level 0-100
VS1053 player(BREAKOUT_CS, BREAKOUT_DCS, DREQ);
void setup() {
Serial.begin(115200);
// reset the breakout
pinMode(BREAKOUT_RESET, OUTPUT);
digitalWrite(BREAKOUT_RESET, LOW);
delay(500);
digitalWrite(BREAKOUT_RESET, HIGH);
// initialize SPI
SPI.begin();
delay(6000);
Serial.println("Hello VS1053!\n");
// initialize a player
player.begin();
player.switchToMp3Mode(); // optional, some boards require this
player.setVolume(VOLUME);
}
void loop() {
Serial.println("Playing sound... ");
// play mp3 flow each 3s
player.playChunk(sampleMp3, sizeof(sampleMp3));
delay(3000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment