0
votes

I am having trouble making this binary counter, to count minutes and seconds. When I try to verify, I get the error below. How do I fix this broken code?

Error message

Expected `;' before '}' token

Code

#define DATA 0
#define LATCH 1
#define CLOCK 2
#define DATA2 3
#define LATCH2 4
#define CLOCK2 5

void setup()

(

    pinMode{LATCH, OUTPUT};
    pinMode(CLOCK, OUTPUT);
    pinMode(DATA, OUTPUT);
    pinMode(LATCH2, OUTPUT);
    pinMode(CLOCK2, OUTPUT);
    pinMode(DATA2, OUTPUT);
)

void loop()
{
    int i;
    for (i = 0; i < 256; i++)
    {
        digitalWrite(LATCH, LOW);
        shiftOut(DATA, CLOCK, MSBFIRST, i);
        digitalWrite(LATCH, HIGH);
        delay(200);
    }
    int c;
    for (c = 0; c < 256; c++)
    {
        digitalWrite(LATCH2, LOW);
        shiftOut(DATA2, CLOCK2, MSBFIRST, c);
        digitalWrite(LATCH2, HIGH);
        delay(100)
    }
}
1
Is that first "pinMode{LATCH, OUTPUT};" supposed to have {}s and not ()s? Which line do you get the error message on?Gaurav
Fixed the "{LATCH, OUTPUT};", but there is still an error there.Jonathan Larsen

1 Answers

2
votes

The problem is in this section (also pinMode{LATCH, OUTPUT};, as in comments):

void setup()

(

    pinMode{LATCH, OUTPUT};
    pinMode(CLOCK, OUTPUT);
    pinMode(DATA, OUTPUT);
    pinMode(LATCH2, OUTPUT);
    pinMode(CLOCK2, OUTPUT);
    pinMode(DATA2, OUTPUT);
)

The parenthesis pair should be a pair of curly brackets (braces):

void setup()

{

    pinMode(LATCH, OUTPUT);
    pinMode(CLOCK, OUTPUT);
    pinMode(DATA, OUTPUT);
    pinMode(LATCH2, OUTPUT);
    pinMode(CLOCK2, OUTPUT);
    pinMode(DATA2, OUTPUT);
}