Programming error message

so i’m programming my arduino when i come across an issue whenever i try to compile. whenever i try to compile it gives me an error message saying “expected initializer before 'int”. the part highlighted when i get the error message is int sensorValue; under void loop. can anybody help?

custom_code_1.ino (1.94 KB)

  void loop()
  // put your main code here, to run repeatedly:{

     int sensorValue;

You commented out your opening brace on loop.

I think I added more than the single ‘{’

int sensorPin = A0;
int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9};

void setup()
{
  for (byte index = 0; index <= 7; index++)
  {
    pinMode(ledPins[index], OUTPUT);
  }
}

void loop()
{
  int sensorValue = analogRead(sensorPin);

  // turn all the LEDs on:

  digitalWrite(ledPins[0], HIGH);  //Turns on LED #0 (pin 2)
  delay(sensorValue);
  digitalWrite(ledPins[1], HIGH);  //Turns on LED #1 (pin 3)
  delay(sensorValue);
  digitalWrite(ledPins[2], HIGH);  //Turns on LED #2 (pin 4)
  delay(sensorValue);
  digitalWrite(ledPins[3], HIGH);  //Turns on LED #3 (pin 5)
  delay(sensorValue);
  digitalWrite(ledPins[4], HIGH);  //Turns on LED #4 (pin 6)
  delay(sensorValue);
  digitalWrite(ledPins[5], HIGH);  //Turns on LED #5 (pin 7)
  delay(sensorValue);
  digitalWrite(ledPins[6], HIGH);  //Turns on LED #6 (pin 8)
  delay(sensorValue);
  digitalWrite(ledPins[7], HIGH);  //Turns on LED #7 (pin 9)
  delay(sensorValue);

  // turn all the LEDs off:

  digitalWrite(ledPins[7], LOW);   //Turn off LED #7 (pin 9)
  delay(sensorValue);
  digitalWrite(ledPins[6], LOW);   //Turn off LED #6 (pin 8)
  delay(sensorValue);
  digitalWrite(ledPins[5], LOW);   //Turn off LED #5 (pin 7)
  delay(sensorValue);
  digitalWrite(ledPins[4], LOW);   //Turn off LED #4 (pin 6)
  delay(sensorValue);
  digitalWrite(ledPins[3], LOW);   //Turn off LED #3 (pin 5)
  delay(sensorValue);
  digitalWrite(ledPins[2], LOW);   //Turn off LED #2 (pin 4)
  delay(sensorValue);
  digitalWrite(ledPins[1], LOW);   //Turn off LED #1 (pin 3)
  delay(sensorValue);
  digitalWrite(ledPins[0], LOW);   //Turn off LED #0 (pin 2)
  delay(sensorValue);
}

Oh yeah, also missing the closing brace on setup.

In the future:
Attach your code using the </> icon on the left side of the posting menu.

ok so it looks like all of my issues were fixed and my code works now. thanks to all that chipped in on advice!