Expected declaration before "}"

I have this code to make a 3 digit sort of display with 3 LEDs and a 7 segment display all hooked up to the Arduino. It is for showing the BPM on my metronome I am making. Although, when I try to upload, it gives the error message in the subject. Can anyone help?

sketch_aug01a.ino (6.9 KB)

Line 248 is screwed up - you have a ; after the if, and you don't have an open brace for the block, but you do have a close brace. This causes it to error on the final close brace of the code, since there's no matching open brace of it.

Also, every one of your if conditions is wrong.

if (variable = 1) doesn't do what you thing. A single equals sign "=" is for assignment, not comparison.

To compare values, use "==" (ie, if (variable==1) )

Why did you post a programming question in installation and troubleshooting section instead of programming questions section?

Put these in setup() :




These need this:

digitA-1; should be: digitA = digitA -1;

These need == :

if (digitA=1)

You don't need to use pinMode() to set pins to be INPUT unless they can be set to something else - all pins start as inputs. In setup, you are guaranteed that the pins are already input.

It is helpful to have the pinMode() calls there to remind you which pins you're using as inputs, but you don't have to.

These all need pinMode as OUTPUTs in setup( ) also:








(Why does the forum add so many blank lines when pasting in code snippets? Dumb)

Thanks for the tips! Also, sorry for posting this in the wrong forum section..

After testing it again with the corrections suggested, and I mean all of them, it was fixed. Thanks!

(Why does the forum add so many blank lines when pasting in code snippets? Dumb)

Because you did not use code tags :smiley: :smiley:

Just joking :wink:

Thanks whoever moved this thread!