aurduino duo with eth shield loading wav files using TMRpcm

hi there working on a project were the program loads wav files for the sd card when a button is pressed loaded the lib in ect code wont run. anyone see anything wrong with my code that im missing. had a good old look around the forums for similar problems.

#include "SD.h" //Lib to read SD card
#include "TMRpcm.h" //Lib to play auido
#include "SPI.h" //SPI lib for SD card
#define SD_ChipSelectPin 13 //Chip select is pin number 13
TMRpcm audio; //Lib object is named "audio"
int wheel = 2;
int button = 4;
int lever1 = 7;
int lever2 = 8;
int led1 = 14;
int led2 = 15;
int led3 = 16;
int led4 = 17;
int led5 = 18;
void setup() {
audio.speakerPin = 9; //Auido out on pin 9
Serial.begin(9600); //Serial Com for debugging
if (!SD.begin(SD_ChipSelectPin)) {
Serial.println("SD fail");
return;
}

pinMode(wheel, INPUT_PULLUP); //Button 1 with internal pull up WHEEL
pinMode(button, INPUT_PULLUP); //Button 2 with internal pull up BUTTON
pinMode(lever1, INPUT_PULLUP); //Button 3 with internal pull LEVER 1
pinMode(lever2, INPUT_PULLUP); //button 4 WITH PULL UP LEVER2
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
audio.setVolume(5); // 0 to 7. Set volume level
audio.quality(0); // Set 1 for 2x oversampling Set 0 for normal
//audio.volume(0); // 1(up) or 0(down) to control volume
//audio.play("filename",30); plays a file
}

void loop()
{

if (digitalRead(wheel) == HIGH); //WHEEL IS ROTATED
{
{
audio.play("wheel.wav"); //Play WHEEL

{
digitalWrite(led1, HIGH); //light led1
}
{ if (digitalRead(button) == LOW); //WHEEL IS NOT ROTATED
{
digitalWrite(led2, LOW); //led off
}
}
if (digitalRead(button) == HIGH); //Button 2 Pressed
{
{
audio.play("button.wav"); //Play BUTTON
digitalWrite(led2, HIGH); // led on
{
{ if (digitalRead(button) == LOW); //Button 2 NOTPressed
digitalWrite(led2, LOW); // led off
}
}
if (digitalRead(lever1) == HIGH); //LEVER 1 IS SWICHED
{
{
audio.play("lever1.wav"); //Play LEVER1
digitalWrite(led3, HIGH);//led on
{
{ if (digitalRead(lever1) == LOW); //LEVER 1 IS NOT SWICHED
digitalWrite(led3, LOW);//led off
}
}
if (digitalRead(lever2) == HIGH) //LEVER 2 IS SWICHED
{
{
audio.play("lever2.wav"); //Play LEVER2
digitalWrite(led4, HIGH);//led on
}
{ if (digitalRead(lever2) == LOW); //LEVER 2 IS NOT SWICHED
digitalWrite(led4, LOW); // led off
{
}

}
if (digitalRead(wheel), (button), (lever1), (lever2) == HIGH); //EVERYTHING IS PRESENT
{
{
audio.play("fanfare.wav"); //Play FANFARE

digitalWrite(led5, HIGH); //led on
}

}

F:\VENDOR\VENDOR.ino:78:42: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

audio.play("lever2.wav"); //Play LEVER2

and lots of

VENDOR:96:17: error: expected '}' at end of input

at the end

any ideas? :o

  if (digitalRead(wheel) == HIGH); //WHEEL IS ROTATED
  {
    {

It is unusual to see a properly written if statement end with a semicolon.
It is unusual to see properly written code with two open curly braces in a row.

Sort out the useless curly braces from the necessary ones, and you'll see what the problem is.

                { if (digitalRead(lever2) == LOW); //LEVER 2 IS NOT SWICHED

Code NEVER follows a { on the same line.

yeah looks like alot, ive removed them still has the same error C:\Users\mark\Desktop\sketch_apr18a\sketch_apr18a.ino:44:27: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

{audio.play("wheel.wav");} //Play WHEEL

still seems like the TMRpcm library doesn't like my syntax, anyone got this working?

Try this:

audio.play((char *)"wheel.wav");

nice work paul, that sorted it out. is karma good :slight_smile: still got another error I'm sure it's just some sort of punctuation

error: expected constructor, destructor, or type conversion before '(' token

pinMode(wheel,INPUT_PULLUP); //Button 1 with internal pull up WHEEL

eyes are crossing together now reading searches. not sure if i could do it differently :o

error: expected constructor, destructor, or type conversion before '(' token

pinMode(wheel,INPUT_PULLUP); //Button 1 with internal pull up WHEEL

When the line being referenced looks correct, look before that line, to see if there is a problem with that line.

The line before the one that the compiler complained about is the curly brace that ends setup(). You can't make function calls outside of a function.

#include "SD.h" //Lib to read SD card
#include "TMRpcm.h" //Lib to play auido
#include "SPI.h" //SPI lib for SD card
#define SD_ChipSelectPin 13 //Chip select is pin number 13
TMRpcm audio; //Lib object is named "audio"
int wheel = 2;
int button = 4;
int lever1 = 7;
int lever2 = 8;
int led1 = 14;
int led2 = 15;
int led3 = 16;
int led4 = 17;
int led5 = 18;
void setup() {
audio.speakerPin = 9; //Auido out on pin 9
Serial.begin(9600); //Serial Com for debugging
if (!SD.begin(SD_ChipSelectPin))
Serial.println("SD fail");
return;
}

pinMode(wheel,INPUT_PULLUP); //Button 1 with internal pull up WHEEL
pinMode(button,INPUT); //Button 2 with internal pull up BUTTON
pinMode(lever1,INPUT); //Button 3 with internal pull LEVER 1
pinMode(lever2,INPUT); //button 4 WITH PULL UP LEVER2
pinMode(led1,OUTPUT); //led1
pinMode(led2,OUTPUT); //led2
pinMode(led3,OUTPUT); //led3
pinMode(led4,OUTPUT);
pinMode(led5,OUTPUT);
audio.setVolume(5); // 0 to 7. Set volume level
audio.quality(1); // Set 1 for 2x oversampling Set 0 for normal
//audio.volume(0); // 1(up) or 0(down) to control volume
//audio.play("filename",30); plays a file
void loop() {

if (digitalRead(wheel) == HIGH) //WHEEL IS ROTATED

audio.play((char *)"wheel.wav"); //Play WHEEL

digitalWrite(led1, HIGH); //light led1

if (digitalRead(button) == LOW) //WHEEL IS NOT ROTATED

digitalWrite(led2, LOW); //led off

if (digitalRead(button) == HIGH) //Button 2 Pressed

audio.play((char *)"button.wav"); //Play BUTTON

digitalWrite(led2, HIGH); // led on

if (digitalRead(button) == LOW) //Button 2 NOTPressed
digitalWrite(led2, LOW); // led off

if (digitalRead(lever1) == HIGH) //LEVER 1 IS SWICHED

audio.play((char *)"lever1.wav"); //Play LEVER1

digitalWrite(led3, HIGH);//led on

if (digitalRead(lever1) == LOW) //LEVER 1 IS NOT SWICHED
digitalWrite(led3, LOW);//led off

if (digitalRead(lever2) == HIGH) //LEVER 2 IS SWICHED

audio.play((char *)"lever2.wav"); //Play LEVER2

digitalWrite(led4, HIGH);//led on

if (digitalRead(lever2) == LOW) //LEVER 2 IS NOT SWICHED
digitalWrite(led4, LOW); // led off

if (digitalRead(wheel), (button), (lever1), (lever2) == HIGH) //EVERYTHING IS PRESENT

audio.play((char *)"wheel.wav"); //Play FANFARE

digitalWrite(led5, HIGH); //led on

}

C:\Users\mark\Desktop\VENDOR\VENDOR.ino: In function 'void loop()':

C:\Users\mark\Desktop\VENDOR\VENDOR.ino:45:28: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

audio.play("wheel.wav"); //Play WHEEL

^

C:\Users\mark\Desktop\VENDOR\VENDOR.ino:58:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

audio.play("button.wav"); //Play BUTTON

^

C:\Users\mark\Desktop\VENDOR\VENDOR.ino:68:38: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

audio.play("lever1.wav"); //Play LEVER1

^

C:\Users\mark\Desktop\VENDOR\VENDOR.ino:78:42: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

audio.play("lever2.wav"); //Play LEVER2

^

C:\Users\mark\Desktop\VENDOR\VENDOR.ino:90:45: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

audio.play("fanfare.wav"); //Play FANFARE

^

VENDOR:96:17: error: expected '}' at end of input

}

^

VENDOR:96:17: error: expected '}' at end of input

VENDOR:96:17: error: expected '}' at end of input

VENDOR:96:17: error: expected '}' at end of input

VENDOR:96:17: error: expected '}' at end of input

VENDOR:96:17: error: expected '}' at end of input

VENDOR:96:17: error: expected '}' at end of input

VENDOR:96:17: error: expected '}' at end of input

exit status 1
expected '}' at end of input

thats the full thing again, many thanks for helping Paul cant beleve im still awake.

void setup() {
  audio.speakerPin = 9; //Auido out on pin 9
  Serial.begin(9600); //Serial Com for debugging
  if (!SD.begin(SD_ChipSelectPin))
    Serial.println("SD fail");
    return;
  }

That is your setup() function. It looks like you failed to use curly braces after the if statement. It looks like you are clueless about what the return is going to accomplish.

You STILL have a lot of code between the end of setup() and the start of loop(). That is STILL not allowed.