Compiling My Curly Braces

Hi Guys

I wonder if one of you would help me with my code .. .. ..

This is still my Grandkids Christmas present .. ..

I've have this code working in another version, but I've tried to alter it so that the wave files play coincident with an LED on, rather than a button push.

I'm getting error codes for curly braces problems but I can't find any .. .. however, I'm very much a novice and probably missing something obvious.

Code is appended .. .. error codes are here .. ...

Arduino: 1.6.5 (Windows 7), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Button_Hero_6a.ino: In function 'void loop()':
Button_Hero_6a:100: error: expected '}' before 'else'
Button_Hero_6a:100: error: expected '}' before 'else'
Button_Hero_6a:104: error: 'else' without a previous 'if'
Button_Hero_6a:108: error: 'else' without a previous 'if'
Button_Hero_6a:112: error: 'else' without a previous 'if'
Button_Hero_6a.ino: At global scope:
Button_Hero_6a:318: error: 'lostHealth' does not name a type
Button_Hero_6a:319: error: expected declaration before '}' token
expected '}' before 'else'

I think line 100 to 112 are the problem; I think 318 & 319 will go away when this is right.

Thanks for your time .. ...

S

Button_Hero_6a.ino (8.73 KB)

if (digitalRead(8) == HIGH);{

Oops.

Hi AWOL

Sorry, I don't understand ?

if (digitalRead(8) == HIGH);{

have you ever seen an "if" written like that, with a semicolon?

Your if/else statements should not have semicolons directly following the condition test.

Compare line 97 with line 129.

Also, you haven't closed the curly bracket for the opening one on line 97. This becomes more evident if you auto format in the Arduino IDE.

Hi Guys

Perhaps I should have mentioned you're dealing with an idiot !! :slight_smile:

Thanks very much problem solved !

S

CTRL-T in the IDE next time, will help you find errors.
Gets easier with practice.