Hi, was wondering if there is a library for synchronous playback of .wav files from a microSD card, am currently using the TMRpcm library, which works great, but does not support asynchronous playback.
Hardware I am currently using:
Arduino Uno
microSD Card Reader:
Sparkfun breakout board for microSD transflash
3.5mm jack connected to earphones
and that is basically it. Attached below is my code for reference
#include <SD.h>
#define SD_ChipSelectPin 4
#include <TMRpcm.h>
#include <SPI.h>
TMRpcm tmrpcm;
int debounceDelay = 50;
int leftPedal = 7;
int iLeftPedal = 0;
long leftPedalDebounce;
int rightPedal = 8;
int iRightPedal = 0;
long rightPedalDebounce;
void setup()
{
tmrpcm.speakerPin = 9;
Serial.begin(9600);
if (!SD.begin(SD_ChipSelectPin))
{
Serial.println("SD fail");
return;
}
else
{
Serial.println("SD ok");
}
tmrpcm.setVolume(6);
pinMode(leftPedal, INPUT_PULLUP);
pinMode(rightPedal, INPUT_PULLUP);
}
void loop()
{
if (digitalRead(leftPedal) != iLeftPedal)
{
leftPedalDebounce = millis();
}
// Right Pedal Control Code
if (digitalRead(leftPedal) == 0 && iLeftPedal == 0 && (millis() - leftPedalDebounce) > debounceDelay)
{
tmrpcm.play("Crash.wav");
iLeftPedal++;
//Serial.println("A");
}
else if (digitalRead(leftPedal) == 1 && iLeftPedal == 1 && (millis() - leftPedalDebounce) > debounceDelay)
{
iLeftPedal--;
//Serial.println("a");
}
// Right Pedal Control Code
if (digitalRead(rightPedal) != iRightPedal)
{
rightPedalDebounce = millis();
}
// Right Pedal Control Code
if (digitalRead(rightPedal) == 0 && iRightPedal == 0 && (millis() - rightPedalDebounce) > debounceDelay)
{
tmrpcm.play("Ride.wav");
iRightPedal++;
//Serial.println("B");
}
else if (digitalRead(rightPedal) == 1 && iRightPedal == 1 && (millis() - rightPedalDebounce) > debounceDelay)
{
iRightPedal--;
//Serial.println("b");
}
}