@jazzmagic, Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project See About the Installation & Troubleshooting category.
Please edit your post, select all code and click the </> button to apply so-called code tags and next save your post. It makes it easier to read, easier to copy and prevents the forum software from incorrect interpretation of the code.
After using tools -> autoformat in the IDE, your sketch looks like this
int buttonState = 0;
void setup()
{
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(0, INPUT);
}
void loop()
{
buttonState = digitalRead(0);
if (buttonState == HIGH) {
{
for (int i = 2; i < 10; i++)
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
}
}
}
else
{
for (int k = 2; k < 10; k++)
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
}
}
Two } at the beginning of a line at the end of the sketch after an autoformat indicates a mismatch of { and }.
An else at the beginning of a line indicates a problem. This is caused by the } just before that which indicates the end of the loop() function; so the rest of the code is outside a function.
The below after an autoformat might indicate a problem. It means that only digitalWrite(2, HIGH);
is part of the for-loop; possibly not what you want.
for (int i = 2; i < 10; i++)
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);