wave shield error

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)

The error check in the IDE said:

error: expected ';' before '}' token
'error_P' was not declared in this scope

PLEASE HELP ME!!!

Get rid of that stupid # define statement. If the error happens, "wasting" a few bytes of SRAM to hold the error message is not the end of the world. Saving those few bytes is not likely to make the difference between success and failure.

i tried that, but then the IDE didn't recognize any 'error' statements. :frowning:

ok.
hi again!
The code errors made me go ballistic so i just deleted the whole sketch!
Another reason is that i probably didn't write the code properly either, so, yeah.

So, does anyone know how to program an adafruit wave shield v1.1 on an arduino uno to play a sound when a button is pressed.

i have one sound and i need one button to play it!

please help!

Arduinofreaklol

ok people!!!
arduinofreaklol here!
i have some code for my shield:

#include "WaveHC.h"
#include "WaveUtil.h"

SdReader card;
FatVolume vol;
FatReader root;
WaveHC wave;

uint8_t dirLevel;
dir_t dirBuf;

int ledValue = 0;
int ledPin = 6;
int up = 1;
int delayTime;

#define error(msg) error_P(PSTR(msg))

void play(FatReader &dir);

void setup() {
Serial.begin(9600);
pinMode(6, OUTPUT);
pinMode(17, OUTPUT);

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("Files found (* = fragmented):");

root.ls(LS_R | LS_FLAG_FRAGMENTED);
}

void loop() {

delay(500);
root.rewind();
play(root);
ledValue = 0;
analogWrite(ledPin, ledValue);

delayTime = 7 * 60 * 1000;
delay(delayTime);
Serial.println("loopit");
}

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(uint8_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();

uint8_t n = 0;
while(wave.isplaying) {
if(up == 1) {
ledValue = ledValue + 3;
} else {
ledValue = ledValue - 3;
}

if(ledValue > 255) {
up = 0;
ledValue = ledValue - 3;
} else if(ledValue < 0) {
up = 1;
ledValue = ledValue + 3;
}
analogWrite(ledPin, ledValue);

putstring(".");
if(!(++n % 32)) Serial.println();
delay(100);
}
sdErrorCheck();
}
}
}
}

ok!
so it worked...but it didn't play a sound!

When I pressed the Reset button on my Arduino Uno R3,
the L light(on the Uno) blinked, followed by the TX light(also on the Uno) flashing 1 or 2 times!
Does that mean the sound is playing?
Because i didn't hear anything!

PLEASE HELP!!!

arduinofreaklol

Please read the two posts at the top of this Forum by Nick Gammon on guidelines for posting here, especially the use of code tags which make the code looklike thiswhen posting source code files. Also, before posting the code, use Ctrl-T in the IDE to reformat the code in a standard format, which makes it easier for us to read.

If you have already posted without using code tags, open your message and select "modify" from the pull down menu labelled, "More", at the lower left corner of the message. Highlight your code by selecting it (it turns blue), and then click on the "</>" icon at the upper left hand corner. Click on the "Save" button.

Far too much code for a damned program that doesn't work. Instead of trying to play every damned file on the card, PLAY ONE FILE THAT YOU KNOW EXISTS.

Ditch 90% of that crap UNTIL YOU KNOW THAT THE HARDWARE WORKS!

Ok!
I'll say two things, Pual_S

  1. please do not use crude language in this forum.

  2. i only have 1 file on the SD card.

The point of this forum is to help me program a wave shield on an arduino uno R3 to, when a button is pressed, play a sound.

the code above was a test to make sure that the shield worked.
it was not the actual code.

So, you going to help me? (which, you are not)
or are you just going to give me useless junk!?

arduinofreaklol