MP3 shield VS1053 on Arduino
FunduinoPublished on
MP3-Dateien vom Arduino abspielen lassen
You need this
VS1053 MP3 Shield - microSD slot, 3.5 mm jack, for Arduino UNO R3
10,61 € *Item no. F23108448About the product — VS1053 MP3 Shield - microSD slot, 3.5 mm jack, for Arduino UNO R3
Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
11,12 € *Item no. F23107480About the product — Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
All 2 parts together 21,73 € *Ready to ship immediately · Delivery time: 1-3 business days
* All prices include statutory VAT, plus shipping costs.
The MP3 Shield VS1053
Prepare the SD card and libraries
Play a file
Play an MP3 file on a loop
#include <SPI.h> // libraries
#include <SdFat.h>
#include <vs1053_SdFat.h>
SdFat sd; //Name the SD card
vs1053 MP3player; //Name the MP3 Shield "MP3Player"
int t=6000; //The value of "t" specifies the time interval between playing the file in the code.
void setup() {
if(!sd.begin(SD_SEL, SPI_FULL_SPEED)) sd.initErrorHalt(); //Read the SD card containing the MP3 files
if (!sd.chdir("/")) sd.errorHalt("sd.chdir");
MP3player.begin(); //Start the MP3 Shield
MP3player.setVolume(10,10); //Set the volume
}
void loop() {
MP3player.available();
MP3player.playTrack(3); //The MP3 Shield now plays the MP3 file named "track001". For a file named "track002", use "2" instead of "1" in these parentheses.
delay(t); //Previously specified pause
}Extension: Announce temperature
Play the sound file corresponding to the measured temperature
#include <SPI.h> // libraries
#include <SdFat.h>
#include <vs1053_SdFat.h>
SdFat sd; //Name the SD card
vs1053 MP3player; //Name the MP3 shield "MP3Player"
int LM35 = A0; //Connect the sensor to analog pin A0. From now on, we’ll call this pin "LM35"
int sensorwert; //Create a variable for the sensor reading
int temperatur = 0; //The temperature value will later be stored in the variable "temperatur".
int t=6000; //The value of "t" specifies the time intervals between individual measurements in the code.
void setup() {
Serial.begin(9600); //Start the serial connection
if(!sd.begin(9, SPI_HALF_SPEED)) sd.initErrorHalt(); //Read the MP3 files from the SD card
if (!sd.chdir("/")) sd.errorHalt("sd.chdir");
MP3player.begin(); //Start the MP3 shield
MP3player.setVolume(10,10); //Set the volume
}
void loop() {
MP3player.available();
sensorwert=analogRead(LM35); //Read the sensor value.
temperatur= map(sensorwert, 0, 307, 0, 150); //Convert the sensor value using the "map" command.
Serial.println(temperatur); //Display the temperature in the serial monitor
MP3player.playTrack(temperatur); //The MP3 shield now plays the file with the matching filename, depending on the measured temperature.
delay(t); //Previously specified pause
}Rate the instructions