So the subject pretty much says what I am trying to do.
I have the speaker to digital 3 and ground.
The SD Reader is wired with CLK to digital 7.
The LEDs are working splendidly.
The sensor is wired from digital 2 and ground.
I am using an UNO
I am new at all of this and have completely hit a wall.
The following is the coding. When I have the serial Monitor up it is telling me that the SD Fails.
Any insight would be greatly appreciated.
Thanks.
#include <SD.h>
#include <TMRpcm.h>
#include <SPI.h>
const int switchPin = 2;
const int ledPin = 13;
const int speakerPin = 3;
const int SDPin = 7;
TMRpcm TMRpcm;
void setup() {
pinMode(switchPin, INPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(switchPin, HIGH);
}
void loop() {
if(digitalRead(switchPin) == LOW){
digitalWrite(ledPin, LOW);
}
else{
digitalWrite(ledPin, HIGH);
TMRpcm.speakerPin=3;
Serial.begin(9600);
if(!SD.begin(SDPin))
{
Serial.println("SD fail");
return;
}
TMRpcm.setVolume(8);
TMRpcm.play("lastime.wav");
}
}