Hello,
I just don't understand whats wrong. I have 3 buttons and every should play another sound, if you press it. Later, it should have 16 buttons and every should play another sound. The songs should play until end. But the program doesn't work.. There is no error message or something else, but I easily can't hear anything. This is our Arduino Uno board together with the Audio Shield ASA1:
And this is the program which doesn't work:
#include <SD.h>
#include <SPI.h>
#include <AudioShield.h>const int buttonPin = 2; // the number of the pushbutton pin
const int buttonPin2 = 3; // the number of the second pushbutton pin
const int buttonPin3 = 4; // the number of the third pushbutton pin// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
int buttonState2 = 0; // variable for reading the second pushbutton status
int buttonState3 = 0; // variable for reading the third pushbutton statusvoid setup() {
if( SD.begin( SD_CS ) == false )
{
return;
}pinMode(buttonPin, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);VS1011.begin();
}void loop(){
buttonState = digitalRead(buttonPin);
buttonState2 = digitalRead(buttonPin2);
buttonState3 = digitalRead(buttonPin3);if (buttonState == HIGH) {
unsigned char buffer[32];
File SoundFile = SD.open( "002.mp3", FILE_READ );
VS1011.UnsetMute();
while( SoundFile.available() )
{
SoundFile.read( buffer, sizeof(buffer) );
VS1011.Send32( buffer );
}
VS1011.Send2048Zeros();
VS1011.SetMute();
SoundFile.close();
}
else { delay(1000); }if (buttonState2 == HIGH) {
unsigned char buffer[32];
File SoundFile = SD.open( "003.mp3", FILE_READ );
VS1011.UnsetMute();
while( SoundFile.available() )
{
SoundFile.read( buffer, sizeof(buffer) );
VS1011.Send32( buffer );
}
VS1011.Send2048Zeros();
VS1011.SetMute();
SoundFile.close();
}
else { delay(1000); }if (buttonState3 == HIGH) {
unsigned char buffer[32];
File SoundFile = SD.open( "004.mp3", FILE_READ );
VS1011.UnsetMute();
while( SoundFile.available() )
{
SoundFile.read( buffer, sizeof(buffer) );
VS1011.Send32( buffer );
}
VS1011.Send2048Zeros();
VS1011.SetMute();
SoundFile.close();
}
else { delay(1000); }
}