0

I keep getting the error "Expected initializer" at different points in my code whenever I try to verify it. Currently, the error exists before "void setup." How can I fix this error and not allow it to happen in the future?

int ledPins[] = {9, 8, 7, 6};
int index;
int currentLED


void setup();
  {
  pinMode(Led1Pin, OUTPUT);
  pinMode(Led2Pin, OUTPUT);
  pinMode(Led3Pin, OUTPUT);
  pinMode(Led4Pin, OUTPUT);
  pinMode(Led5Pin, OUTPUT);
  pinMode(ButtonPin, INPUT);

  Serial.begin(9600);

  //Start a new game.




 for(index = 0; index <= 4; index++)
  {
    pinMode(ledPins[index],OUTPUT);
    // ledPins[index] is replaced by the value in the array.
    // For example, ledPins[0] is 2
  }
}



void loop()
{

  oneAfterAnotherNoLoop();  // Light up all the LEDs in turn


}

void oneAfterAnotherNoLoop()
{
  int delayTime = 200; // time (milliseconds) to pause between LEDs
                   // make this smaller for faster switching
  // turn all the LEDs on:
  int Index;

for (Index = 0; Index <=3; Index++) {
  digitalWrite(ledPins[Index], HIGH);
  delay(delayTime);
  digitalWrite(ledPins[Index], LOW);
}
for (Index = 3; Index >= 0; Index--) {
    digitalWrite(ledPins[Index], HIGH);
  delay(delayTime);
  digitalWrite(ledPins[Index], LOW);
}
}

void loop();
{
    // Check if the button is pressed at the right moment

   if (digitalRead(10) == 0) 
   {
    if (currentLED == 8)
    {
      // Blink the orrect (green) LED
      digitalWrite(8, HIGH);
      delay(200);
      digitalWrite(14, LOW);
      delay(200);
      digitalWrite(8, HIGH);
      delay(200);
      digitalWrite(14, LOW);
    }
    }
  }

closed as off-topic by gre_gor, VE7JRO, MatsK, Dmitry Grigoryev, SDsolar Jun 21 '18 at 2:20

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be about Arduino, within the scope defined in the help center." – gre_gor, VE7JRO, MatsK, Dmitry Grigoryev, SDsolar
If this question can be reworded to fit the rules in the help center, please edit the question.

  • For starters, int currentLED is not a valid C++ declaration: you're missing a semicolon. On the other hand, void setup();{} has an extra semicolon which should be removed. – Dmitry Grigoryev Jun 19 '18 at 12:20
3
int currentLED

You are missing a semicolon there.


void setup();

There should not be a semicolon here.


Do some tutorials on the C or C++ language. They will help you.

Not the answer you're looking for? Browse other questions tagged or ask your own question.