Skip to content

Commit

Permalink
update VS1053 examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tigoe committed Oct 17, 2024
1 parent 1fd45f4 commit 5aa17fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
one on the sound player module. To do this, set CARDCS to SDCARD_SS_PIN
created 30 Nov 2018
modified 14 Dec 2018
modified 17 Dec 2024
by Tom Igoe
*/
Expand All @@ -28,6 +28,9 @@
// the VS1053 chip and SD card are both SPI devices.
// Set their respective pins:

#define CLK 13 // SPI Clock, shared with SD card
#define MISO 12 // Input data, from VS1053/SD card
#define MOSI 11 // Output data, to VS1053/SD card
#define VS1053_RESET 6 // VS1053 reset pin
#define VS1053_CS 7 // VS1053 chip select pin
#define VS1053_DCS 4 // VS1053 Data/command select pin
Expand All @@ -42,7 +45,7 @@ Adafruit_VS1053_FilePlayer mp3Player =
Adafruit_VS1053_FilePlayer(VS1053_RESET, VS1053_CS, VS1053_DCS, VS1053_DREQ, CARDCS);

// sound file name must be 8 chars .3 chars:
const char soundFile[] = "SOUND001.MP3";
const char soundFile[] = "/track001.mp3";

void setup() {
Serial.begin(9600);
Expand Down Expand Up @@ -77,6 +80,7 @@ void setup() {
mp3Player.useInterrupt(VS1053_FILEPLAYER_PIN_INT);

// play file:
mp3Player.playFullFile(soundFile);
mp3Player.startPlayingFile(soundFile);
Serial.println("playing");
}
Expand All @@ -86,7 +90,7 @@ void loop() {
// map to a range from 100 to 0:
int loudness = map(analogRead(A0), 0, 1023, 100, 0);
// set the volume:
mp3Player.setVolume(loudness, loudness);
// mp3Player.setVolume(loudness, loudness);

// loop the player:
if (mp3Player.stopped()) {
Expand Down
5 changes: 3 additions & 2 deletions docs/vs1053-mp3.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ Then make an instance of the VS1053 library using the pins you set, and set a st
Adafruit_VS1053_FilePlayer mp3Player =
Adafruit_VS1053_FilePlayer(VS1053_RESET, VS1053_CS, VS1053_DCS, VS1053_DREQ, CARDCS);
// sound file name must be 8 chars .3 chars:
const char soundFile[] = "SOUND001.MP3";
// sound file name must be 8 chars .3 chars and must be the absolute path:
const char soundFile[] = "/SOUND001.MP3";
````

In the `setup()`, initialize serial communication for diagnostic purposes only, then set the pinMode of the pushbutton and the VS1053 reset, then reset the module:
Expand Down Expand Up @@ -145,6 +145,7 @@ Next, set the output volume for the module, enable its fileplayer interrupt pin,
mp3Player.useInterrupt(VS1053_FILEPLAYER_PIN_INT);
// play file:
mp3Player.playFullFile(soundFile);
mp3Player.startPlayingFile(soundFile);
Serial.println("playing");
}
Expand Down

0 comments on commit 5aa17fc

Please sign in to comment.