Hey poeple!
i am a newbie to arduino (i love it!), and i have a problem!
i am trying to program an arduino wave shield version 1.1 to play a sound, but there is an error in the code that i do not know how to fix! here it is:
#include <WaveHC.h>
#include <WaveUtil.h>
SdReader card;
FatVolume vol;
FatReader root;
WaveHC wave;
uint8_t dirLevel;
dir_t dirBuf;
const int keyPin = 12;
#define error(msg) error_P(PSTR(msg)) <-------------this line is said to have an error
according to the IDE. Read bottom
of text!
void play(FatReader &dir); l
V
void setup() {
Serial.begin(9600);
pinMode(keyPin, INPUT);
putstring_nl("\nWave test!");
putstring("Free RAM: ");
Serial.println(FreeRam());
if(!card.init()) {
error("Card init. failed!");
}
card.partialBlockRead(true);
uint8_t part;
for(part = 0; part < 5; part++) {
if(vol.init(card, part))
break;
}
if(part == 5) {
error("No valid FAT partition!");
}
putstring("Using partition ");
Serial.print(part, DEC);
putstring(", type is FAT");
Serial.println(vol.fatType(), DEC);
if(!root.openRoot(vol)) {
error("Can't open root dir!");
}
putstring_nl("File found (* = fragmented):");
root.ls(LS_R | LS_FAG_FRAGMENTED);
}
void loop() {
if(digitalWrite(keyPin == HIGH) {
root.rewind();
play(root);
}
void error_P(const char *str){
PgmPrint("Error: ");
SerialPrint_P(str);
sdErrorCheck();
while(1);
}
void sdErrorCheck(void) {
if(!card.errorCode()) return;
PgmPrint("\r\nSD I/O error: ");
Serial.print(card.errorCode(), HEX);
PgmPrint(", ");
Serial.println(card.errorData(), HEX);
while(1);
}
void play(FatReader &dir) {
FatReader file;
while (dir.readDir(dirBuf) > 0) {
if(!DIR_IS_SUBDIR(dirBuf)
&& strncmp_P((char *)&dirBuf.name[8], PSTR("WAV"), 3)) {
continue;
}
Serial.println();
for(uint*_t i = 0; i < dirLevel; i++) {
Serial.print(' ');
}
if(!file.open(vol, dirBuf)) {
error("file.open failed");
}
if(file.isDir()) {
putstring("Subdir: ");
printEntryName(dirBuf);
dirLevel += 2;
play (file);
dirLevel -= 2;
} else {
putstring("Playing ");
printEntryName(dirBuf);
if(!wave.create(file)) {
putstring("Not a valid WAV");
} else {
Serial.println();
wave.play();
putstring(".");
if(!(++n % 32)) Serial.println();
delay(100);
}
sdErrorCheck();
}
}
}
}
The error check in the IDE said:
error: expected ';' before '}' token
'error_P' was not declared in this scope
PLEASE HELP ME!!!
Thanks,
arduinofreaklol
error picture.zip (26.5 KB)