Created
November 20, 2018 21:28
-
-
Save hz37/17e0c10c28db16f0314491b42c95780b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ********************************************************************* | |
// Manju koffer met Arduino Uno en Adafruit VS1053 shield. | |
// H.Zimmerman, 20-11-2018, Bilthoven. | |
// ********************************************************************* | |
#include <SPI.h> | |
#include <Adafruit_VS1053.h> | |
#include <SD.h> | |
// ********************************************************************* | |
// Switch debug and release modes. | |
// #define DEBUGGING | |
// There is no VS1053 reset pin. | |
#define SHIELD_RESET -1 | |
// VS1053 Data request. | |
#define DREQ 3 | |
// Card chip select pin. | |
#define CARDCS 4 | |
// VS1053 Data/command select pin (output). | |
#define SHIELD_DCS 6 | |
// VS1053 chip select pin (output). | |
#define SHIELD_CS 7 | |
// Def volume at startup. | |
#define DEF_VOLUME 10 | |
// ********************************************************************* | |
// Instance of Adafruit_VS1053_FilePlayer. | |
Adafruit_VS1053_FilePlayer musicPlayer = Adafruit_VS1053_FilePlayer | |
( | |
SHIELD_RESET, | |
SHIELD_CS, | |
SHIELD_DCS, | |
DREQ, | |
CARDCS | |
); | |
uint16_t volume = 0; | |
// ********************************************************************* | |
void setup() | |
{ | |
#ifdef DEBUGGING | |
Serial.begin(9600); | |
Serial.println("Suitcase start."); | |
#endif | |
// Initialise the music player shield. | |
if (!musicPlayer.begin()) | |
{ | |
#ifdef DEBUGGING | |
Serial.println(F("musicPlayer.begin() error.")); | |
#endif | |
while(true); | |
} | |
#ifdef DEBUGGING | |
Serial.println(F("VS1053 found")); | |
#endif | |
if (!SD.begin(CARDCS)) | |
{ | |
#ifdef DEBUGGING | |
Serial.println(F("SD failed, or not present")); | |
#endif | |
while(true); | |
} | |
// Set volume for left, right channels. lower numbers == louder volume!. | |
volume = DEF_VOLUME; | |
musicPlayer.setVolume(volume, volume); | |
} | |
// ********************************************************************* | |
void loop() | |
{ | |
musicPlayer.playFullFile("KOFFER10.MP3"); | |
} | |
// ********************************************************************* | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment