error: expected unqualified-id before '{' token ---please help debug

Code looks like this: (the offending { is the one just above this part of the code:)

{
  //  if (!card.init(true))  
  //play with 8 MHz spi (default faster!)  
  //play with 4 MHz spi if 8MHz isn't working for you
  if (!card.init()) {        
    putstring_nl("Card init. failed!");  // Something went wrong, lets print out why
    sdErrorCheck();
    while(1);                            // then 'halt' - do nothing!

******************my starts to delineate the code starting here

#include <FatReader.h>
#include <SdReader.h>
#include <avr/pgmspace.h>
#include "WaveUtil.h"
#include "WaveHC.h"


#include "WProgram.h"
//?????
void sdErrorCheck(void);
void setup();

void loop();
void playcomplete(char *name);
void playfile(char *name);
SdReader card;    // This object holds the information for the card
FatVolume vol;    // This holds the information for the partition on the card
FatReader root;   // This holds the information for the filesystem on the card
FatReader f;      // This holds the information for the file we're play

WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time

#define DEBOUNCE 5  // button debouncer
#define NUMSOUNDS 7   //how many dasiy sounds i want to play off the sdcard.


char* herSounds[]={"1.wav", "2.wav", "3.wav", "4.wav", "5.wav", "6.wav", "7.wav"};

int ledPin = 13;                // choose the pin for the LED
int inputPin = 6;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status


// this handy function will return the number of bytes currently free in RAM, great for debugging!   
int freeRam(void)

{
  extern int  __bss_end; 
  extern int  *__brkval; 
  int free_memory; 
  if((int)__brkval == 0) {
    free_memory = ((int)&free_memory) - ((int)&__bss_end); 
  }
  else {
    free_memory = ((int)&free_memory) - ((int)__brkval); 
  }
  return free_memory; 
} 

void sdErrorCheck(void)
{
  if (!card.errorCode()) return;
  putstring("\n\rSD I/O error: ");
  Serial.print(card.errorCode(), HEX);
  putstring(", ");
  Serial.println(card.errorData(), HEX);
  while(1);
}

void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as input
  
  // set up serial port
  Serial.begin(9600);
  
  // Set the output pins for the DAC control. This pins are defined in the library
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
}

{
  //  if (!card.init(true))  
  //play with 8 MHz spi (default faster!)  
  //play with 4 MHz spi if 8MHz isn't working for you
  if (!card.init()) {        
    putstring_nl("Card init. failed!");  // Something went wrong, lets print out why
    sdErrorCheck();
    while(1);                            // then 'halt' - do nothing!
  }
  
  // enable optimize read - some cards may timeout. Disable if you're having problems
  card.partialBlockRead(true);

// Now we will look for a FAT partition!
  uint8_t part;
  for (part = 0; part < 5; part++) {     // we have up to 5 slots to look in
    if (vol.init(card, part)) 
      break;                             // we found one, lets bail
  }
  if (part == 5) {                       // if we ended up not finding one  :(
    putstring_nl("No valid FAT partition!");
    sdErrorCheck();      // Something went wrong, lets print out why
    while(1);                            // then 'halt' - do nothing!
  }
  
  // Lets tell the user about what we found
  putstring("Using partition ");
  Serial.print(part, DEC);
  putstring(", type is FAT");
  Serial.println(vol.fatType(),DEC);     // FAT16 or FAT32?
  
  // Try to open the root directory
  if (!root.openRoot(vol)) {
    putstring_nl("Can't open root dir!"); // Something went wrong,
    while(1);                             // then 'halt' - do nothing!
  }
  
  // Whew! We got past the tough parts.
  putstring_nl("Ready!");
  
  TCCR2A = 0;
  TCCR2B = 1<<CS22 | 1<<CS21 | 1<<CS20;

  //Timer2 Overflow Interrupt Enable
  TIMSK2 |= 1<<TOIE2;


}

void loop(){
  val = digitalRead(inputPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, HIGH);  // turn LED ON
    if (pirState == LOW) {
      // we have just turned on
      int x = random(NUMSOUNDS);
      playcomplete(herSounds[x]);
      Serial.println("Motion detected!");
      // We only want to print on the output change, not state
      pirState = HIGH;
    }
  } else {
    digitalWrite(ledPin, LOW); // turn LED OFF
    if (pirState == HIGH){
      // we have just turned of
      Serial.println("Motion ended!");
      // We only want to print on the output change, not state
      pirState = LOW;
    }
  }
}  

// Plays a full file from beginning to end with no pause.
void playcomplete(char *name) {
  // call our helper to find and play this name
  playfile(name);
  while (wave.isplaying) {
  // do nothing while its playing
  }
  // now its done playing
}

void playfile(char *name) {
  // see if the wave object is currently doing something
  if (wave.isplaying) {// already playing something, so stop it!
    wave.stop(); // stop it
  }
  // look in the root directory and open the file
  if (!f.open(root, name)) {
    putstring("Couldn't open file "); Serial.print(name); return;
  }
  // OK read the file and turn it into a wave object
  if (!wave.create(f)) {
    putstring_nl("Not a valid WAV"); return;
  }
  
  // ok time to play! start playback
  wave.play();
}

int main(void)
{
	init();

	setup();
    
	for (;;)
		loop();
        
	return 0;
}

Moderator edit: Code put into code box. Please use the # icon on the editor's toolbar when posting code. AWOL

Just going to look at this now - but just for future use the code tag (code in square brackets) is good for pasting code :slight_smile:

EDIT: - Ok think I found it - or something at least

In you setup() under the line

	pinMode(5, OUTPUT);

you have a closing brace followed by an opening brace - but no function declaration

Not sure what you wanted there, but the below code should be ok (ish - was edited in Notepad++)

Hope it helps :slight_smile:

#include <FatReader.h>
#include <SdReader.h>
#include <avr/pgmspace.h>
#include "WaveUtil.h"
#include "WaveHC.h"


#include "WProgram.h"
//?????
void sdErrorCheck(void);
void setup();

void loop();
void playcomplete(char *name);
void playfile(char *name);
SdReader card;    // This object holds the information for the card
FatVolume vol;    // This holds the information for the partition on the card
FatReader root;   // This holds the information for the filesystem on the card
FatReader f;      // This holds the information for the file we're play

WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time

#define DEBOUNCE 5  // button debouncer
#define NUMSOUNDS 7   //how many dasiy sounds i want to play off the sdcard.


char* herSounds[]={"1.wav", "2.wav", "3.wav", "4.wav", "5.wav", "6.wav", "7.wav"};

int ledPin = 13;                // choose the pin for the LED
int inputPin = 6;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status


// this handy function will return the number of bytes currently free in RAM, great for debugging!   
int freeRam(void)
{
	extern int  __bss_end; 
	extern int  *__brkval; 
	int free_memory; 
	if((int)__brkval == 0) 
	{
		free_memory = ((int)&free_memory) - ((int)&__bss_end); 
	}
	else 
	{
		free_memory = ((int)&free_memory) - ((int)__brkval); 
	}
	return free_memory; 
} 

void sdErrorCheck(void)
{
	if (!card.errorCode()) return;
	putstring("\n\rSD I/O error: ");
	Serial.print(card.errorCode(), HEX);
	putstring(", ");
	Serial.println(card.errorData(), HEX);
	while(1);
}

void setup() 
{
	pinMode(ledPin, OUTPUT);      // declare LED as output
	pinMode(inputPin, INPUT);     // declare sensor as input

	// set up serial port
	Serial.begin(9600);

	// Set the output pins for the DAC control. This pins are defined in the library
	pinMode(2, OUTPUT);
	pinMode(3, OUTPUT);
	pinMode(4, OUTPUT);
	pinMode(5, OUTPUT);

	/*
	// ERROR HERE
}

{
	*/

	//if (!card.init(true))  
	//play with 8 MHz spi (default faster!)  
	//play with 4 MHz spi if 8MHz isn't working for you
	if (!card.init()) 
	{        
		putstring_nl("Card init. failed!");  // Something went wrong, lets print out why
		sdErrorCheck();
		while(1);                            // then 'halt' - do nothing!
	}

	// enable optimize read - some cards may timeout. Disable if you're having problems
	card.partialBlockRead(true);

	// Now we will look for a FAT partition!
	uint8_t part;
	for (part = 0; part < 5; part++) 
	{     // we have up to 5 slots to look in
		if (vol.init(card, part)) 
			break;                             // we found one, lets bail
	}
	if (part == 5) 
	{                       // if we ended up not finding one  
		putstring_nl("No valid FAT partition!");
		sdErrorCheck();      // Something went wrong, lets print out why
		while(1);                            // then 'halt' - do nothing!
	}

	// Lets tell the user about what we found
	putstring("Using partition ");
	Serial.print(part, DEC);
	putstring(", type is FAT");
	Serial.println(vol.fatType(),DEC);     // FAT16 or FAT32?

	// Try to open the root directory
	if (!root.openRoot(vol)) 
	{
		putstring_nl("Can't open root dir!"); // Something went wrong,
		while(1);                             // then 'halt' - do nothing!
	}

	// Whew! We got past the tough parts.
	putstring_nl("Ready!");

	TCCR2A = 0;
	TCCR2B = 1<<CS22 | 1<<CS21 | 1<<CS20;

	//Timer2 Overflow Interrupt Enable
	TIMSK2 |= 1<<TOIE2;


}

void loop()
{
	val = digitalRead(inputPin);  // read input value
	if (val == HIGH) 
	{            // check if the input is HIGH
		digitalWrite(ledPin, HIGH);  // turn LED ON
		if (pirState == LOW) 
		{
			// we have just turned on
			int x = random(NUMSOUNDS);
			playcomplete(herSounds
				);
			Serial.println("Motion detected!");
			// We only want to print on the output change, not state
			pirState = HIGH;
		}
	} 
	else 
	{
		digitalWrite(ledPin, LOW); // turn LED OFF
		if (pirState == HIGH)
		{
			// we have just turned of
			Serial.println("Motion ended!");
			// We only want to print on the output change, not state
			pirState = LOW;
		}
	}
}  

// Plays a full file from beginning to end with no pause.
void playcomplete(char *name) 
{
	// call our helper to find and play this name
	playfile(name);
	while (wave.isplaying) 
	{
		// do nothing while its playing
	}
	// now its done playing
}

void playfile(char *name) 
{
	// see if the wave object is currently doing something
	if (wave.isplaying) 
	{// already playing something, so stop it!
		wave.stop(); // stop it
	}
	// look in the root directory and open the file
	if (!f.open(root, name)) 
	{
		putstring("Couldn't open file "); Serial.print(name); return;
	}
	// OK read the file and turn it into a wave object
	if (!wave.create(f)) 
	{
		putstring_nl("Not a valid WAV"); return;
	}

	// ok time to play! start playback
	wave.play();
}

int main(void)
{
	init();

	setup();

	for (;;)
		loop();

	return 0;
}

Thanks so much for your timely reply! I had two errors show up when I copied and pasted the entirety of the code you sent back but then I just copied and pasted the offending error and now I get a new error: SoundBox2_void:138: error: expected initializer before 'void'

arduino IDE highlights this: void loop() {

I can't believe you found that a the issue, I tried many changes to bracketing in that area, thank you! (and for the newbie advice)

#include <FatReader.h>
#include <SdReader.h>
#include <avr/pgmspace.h>
#include "WaveUtil.h"
#include "WaveHC.h"


#include "WProgram.h"
//?????
void sdErrorCheck(void);
void setup();
void check_switches();
void loop();
void playcomplete(char *name);
void playfile(char *name);
SdReader card;    // This object holds the information for the card
FatVolume vol;    // This holds the information for the partition on the card
FatReader root;   // This holds the information for the filesystem on the card
FatReader f;      // This holds the information for the file we're play

WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time

#define DEBOUNCE 5  // button debouncer
#define NUMSOUNDS 7   //how many dasiy sounds i want to play off the sdcard.


char* herSounds[]={"1.wav", "2.wav", "3.wav", "4.wav", "5.wav", "6.wav", "7.wav"};

int ledPin = 13;                // choose the pin for the LED
int inputPin = 6;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status


// this handy function will return the number of bytes currently free in RAM, great for debugging!   
int freeRam(void)

{
  extern int  __bss_end; 
  extern int  *__brkval; 
  int free_memory; 
  if((int)__brkval == 0) {
    free_memory = ((int)&free_memory) - ((int)&__bss_end); 
  }
  else {
    free_memory = ((int)&free_memory) - ((int)__brkval); 
  }
  return free_memory; 
} 

void sdErrorCheck(void)
{
  if (!card.errorCode()) return;
  putstring("\n\rSD I/O error: ");
  Serial.print(card.errorCode(), HEX);
  putstring(", ");
  Serial.println(card.errorData(), HEX);
  while(1);
}

void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as input
  
  // set up serial port
  Serial.begin(9600);
  
  // Set the output pins for the DAC control. This pins are defined in the library
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);

	/*
	// ERROR HERE
}

{
	*/

	//if (!card.init(true))  
	//play with 8 MHz spi (default faster!)  
	//play with 4 MHz spi if 8MHz isn't working for you
	if (!card.init()) 
	{        
		putstring_nl("Card init. failed!");  // Something went wrong, lets print out why
		sdErrorCheck();
		while(1);                            // then 'halt' - do nothing!
	}

	// enable optimize read - some cards may timeout. Disable if you're having problems
	card.partialBlockRead(true);

	// Now we will look for a FAT partition!
	uint8_t part;
	for (part = 0; part < 5; part++) 
	{     // we have up to 5 slots to look in
		if (vol.init(card, part)) 
			break;                             // we found one, lets bail
	}
	if (part == 5) 
	{                       // if we ended up not finding one  
		putstring_nl("No valid FAT partition!");
		sdErrorCheck();      // Something went wrong, lets print out why
		while(1);                            // then 'halt' - do nothing!
	}

	// Lets tell the user about what we found
	putstring("Using partition ");
	Serial.print(part, DEC);
	putstring(", type is FAT");
	Serial.println(vol.fatType(),DEC);     // FAT16 or FAT32?

	// Try to open the root directory
	if (!root.openRoot(vol)) 
	{
		putstring_nl("Can't open root dir!"); // Something went wrong,
		while(1);                             // then 'halt' - do nothing!
	}

	// Whew! We got past the tough parts.
	putstring_nl("Ready!");

	TCCR2A = 0;
	TCCR2B = 1<<CS22 | 1<<CS21 | 1<<CS20;

	//Timer2 Overflow Interrupt Enable
	TIMSK2 |= 1<<TOIE2;


}

SIGNAL(TIMER2_OVF_vect) {
  check_switches();
}

void check_switches()

void loop() {
  val = digitalRead(inputPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, HIGH);  // turn LED ON
    if (pirState == LOW) {
      // we have just turned on
      int x = random(NUMSOUNDS);
      playcomplete(herSounds[x]);
      Serial.println("Motion detected!");
      // We only want to print on the output change, not state
      pirState = HIGH;
    }
  } else {
    digitalWrite(ledPin, LOW); // turn LED OFF
    if (pirState == HIGH){
      // we have just turned of
      Serial.println("Motion ended!");
      // We only want to print on the output change, not state
      pirState = LOW;
    }
  }
}  

// Plays a full file from beginning to end with no pause.
void playcomplete(char *name) {
  // call our helper to find and play this name
  playfile(name);
  while (wave.isplaying) {
  // do nothing while its playing
  }
  // now its done playing
}

void playfile(char *name) {
  // see if the wave object is currently doing something
  if (wave.isplaying) {// already playing something, so stop it!
    wave.stop(); // stop it
  }
  // look in the root directory and open the file
  if (!f.open(root, name)) {
    putstring("Couldn't open file "); Serial.print(name); return;
  }
  // OK read the file and turn it into a wave object
  if (!wave.create(f)) {
    putstring_nl("Not a valid WAV"); return;
  }
  
  // ok time to play! start playback
  wave.play();
}

int main(void)
{
	init();

	setup();
    
	for (;;)
		loop();
        
	return 0;
}
void check_switches()

Just a quick look but that check_switches has no ; and no body.

int main(void)
{
	init();

	setup();
    
	for (;;)
		loop();
        
	return 0;
}

Why?

	// ERROR HERE
}

{  //No, Error here.