Hello. I am building a project for my uncles Christmas present and I need it to play a sound and light up when either of two button are pressed. I am use this tutorial to set up my board
Here's My error
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 (Windows NT (unknown)), Board: "Arduino Nano w/ ATmega328"
WavSW_ino.cpp.o: In functionloop': C:\Program Files (x86)\Arduino/WavSW_ino.ino:28: undefined reference to
TMRpcm::play(char*)'
C:\Program Files (x86)\Arduino/WavSW_ino.ino:36: undefined reference toTMRpcm::play(char*)' WavSW_ino.cpp.o: In function
setup':
C:\Program Files (x86)\Arduino/WavSW_ino.ino:22: undefined reference toTMRpcm::volume(char)' C:\Program Files (x86)\Arduino/WavSW_ino.ino:23: undefined reference to
TMRpcm::play(char*)'
So my code is
#include <SD.h> // need to include the SD library
#define SD_ChipSelectPin 4 //using digital pin 4 on arduino nano 328
#include <C:\Users\L\Documents\Arduino\libraries\TMRpcm-master\TMRpcm/TMRpcm.h> // also need to include this library...
TMRpcm tmrpcm; // create an object for use in this sketch
int inputPin1 = 14;
int inputPin2 = 15;
void setup(){
pinMode(inputPin1, INPUT);
pinMode(inputPin2, INPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
tmrpcm.speakerPin = 9; //11 on Mega, 9 on Uno, Nano, etc
if (!SD.begin(SD_ChipSelectPin)) { // see if the card is present and can be initialized:
return; // don't do anything more if not
}
tmrpcm.volume(1);
tmrpcm.play("1.wav"); //the sound file "1" will play each time the arduino powers up, or is reset
}
void loop(){
if (digitalRead(inputPin1) == LOW) {
tmrpcm.play("6.wav");
digitalWrite(7, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(8, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(7, LOW);
digitalWrite(8, LOW);
}
else if (digitalRead(inputPin2) == LOW) {
tmrpcm.play("6.wav");
digitalWrite(7, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(8, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(7, LOW);
digitalWrite(8, LOW);
}
}
so basically depending on the button pressed the it will light up and play 1 of 2 sound files. I just can't figure out how to solve this error. I thankful for your help.