Here's the code.
Code:
#include <SimpleSDAudio.h>
#define DEBOUNCE 5 // button debouncer
int buttonState = 0;
int buttonPushCounter = 0;
int lastButtonState = 0;
void setup() {
Serial.begin(9600); //start serial comm.
Serial.println("Welcome to the monkey business! Please press a button.");
Serial.println("I will be playing different sounds whenever you select a button.");
SdPlay.setSDCSPin(10); //Using SD shield, need to be 10.
if (!SdPlay.init(SSDA_MODE_FULLRATE | SSDA_MODE_MONO)) { //fullrate, mono output
while(1); // Error while initialization of SD card -> stop.
}
pinMode(10,OUTPUT); //needed for shield
pinMode(14,INPUT); //button I'm trying to give my human input to play file
pinMode(15,INPUT);
pinMode(16,INPUT);
pinMode(17,INPUT);
}
void loop() {
digitalWrite(14, HIGH);
if (digitalRead(14) == LOW) { //This will cause music to be played.
SdPlay.setFile("spoke7.afm"); //play this file.
SdPlay.play(); //play it now.
// Let the worker work until playback is finished
while(!SdPlay.isStopped()){ //apparently this has to do work son!
SdPlay.worker(); } //SdCard Hardhat zone.
}
digitalWrite(15,HIGH);
if (digitalRead(15) == LOW) { //This will cause music to be played.
SdPlay.setFile("spoke8.afm"); //play this file.
SdPlay.play(); //play it now.
// Let the worker work until playback is finished
while(!SdPlay.isStopped()){ //apparently this has to do work son!
SdPlay.worker(); } //SdCard Hardhat zone.
}
digitalWrite(16,HIGH);
if (digitalRead(16) == LOW) { //This will cause music to be played.
SdPlay.setFile("spoke9.afm"); //play this file.
SdPlay.play(); //play it now.
// Let the worker work until playback is finished
while(!SdPlay.isStopped()){ //apparently this has to do work son!
SdPlay.worker(); } //SdCard Hardhat zone.
}
digitalWrite(17,HIGH);
if (digitalRead(17) == LOW) { //This will cause music to be played.
SdPlay.setFile("spoke10.afm"); //play this file.
SdPlay.play(); //play it now.
// Let the worker work until playback is finished
while(!SdPlay.isStopped()){ //apparently this has to do work son!
SdPlay.worker(); } //SdCard Hardhat zone.
}
}
#define DEBOUNCE 5 // button debouncer
int buttonState = 0;
int buttonPushCounter = 0;
int lastButtonState = 0;
void setup() {
Serial.begin(9600); //start serial comm.
Serial.println("Welcome to the monkey business! Please press a button.");
Serial.println("I will be playing different sounds whenever you select a button.");
SdPlay.setSDCSPin(10); //Using SD shield, need to be 10.
if (!SdPlay.init(SSDA_MODE_FULLRATE | SSDA_MODE_MONO)) { //fullrate, mono output
while(1); // Error while initialization of SD card -> stop.
}
pinMode(10,OUTPUT); //needed for shield
pinMode(14,INPUT); //button I'm trying to give my human input to play file
pinMode(15,INPUT);
pinMode(16,INPUT);
pinMode(17,INPUT);
}
void loop() {
digitalWrite(14, HIGH);
if (digitalRead(14) == LOW) { //This will cause music to be played.
SdPlay.setFile("spoke7.afm"); //play this file.
SdPlay.play(); //play it now.
// Let the worker work until playback is finished
while(!SdPlay.isStopped()){ //apparently this has to do work son!
SdPlay.worker(); } //SdCard Hardhat zone.
}
digitalWrite(15,HIGH);
if (digitalRead(15) == LOW) { //This will cause music to be played.
SdPlay.setFile("spoke8.afm"); //play this file.
SdPlay.play(); //play it now.
// Let the worker work until playback is finished
while(!SdPlay.isStopped()){ //apparently this has to do work son!
SdPlay.worker(); } //SdCard Hardhat zone.
}
digitalWrite(16,HIGH);
if (digitalRead(16) == LOW) { //This will cause music to be played.
SdPlay.setFile("spoke9.afm"); //play this file.
SdPlay.play(); //play it now.
// Let the worker work until playback is finished
while(!SdPlay.isStopped()){ //apparently this has to do work son!
SdPlay.worker(); } //SdCard Hardhat zone.
}
digitalWrite(17,HIGH);
if (digitalRead(17) == LOW) { //This will cause music to be played.
SdPlay.setFile("spoke10.afm"); //play this file.
SdPlay.play(); //play it now.
// Let the worker work until playback is finished
while(!SdPlay.isStopped()){ //apparently this has to do work son!
SdPlay.worker(); } //SdCard Hardhat zone.
}
}
Thanks for the help.