programming question

Hi everyone, i'm pretty new and i'm trying to make 9 LED's all flash at once. Is there a way to specify a voidsetup() to a scope, or is there a way to delete the variable at the end of a scope? here is an example of my program

void setup()

{ int yellowled = 2;
pinMode (yellowled, OUTPUT);
digitalWrite(yellowled, HIGH);
delay (1000);
digitalWrite(yellowled, LOW);
delay (1000);
}

void setup()

{int yellowled = 3;
pinMode (yellowled, OUTPUT);
digitalWrite(yellowled, HIGH);
delay (1000);
digitalWrite(yellowled, LOW);
delay (1000);
}

void setup()

{int yellowled = 4;
pinMode (yellowled, OUTPUT);
digitalWrite(yellowled, HIGH);
delay (1000);
digitalWrite(yellowled, LOW);
delay (1000);
}

void setup()

{int yellowled = 5;
pinMode (yellowled, OUTPUT);
digitalWrite(yellowled, HIGH);
delay (1000);
digitalWrite(yellowled, LOW);
delay (1000);
}

void setup()

{int yellowled = 6;
pinMode (yellowled, OUTPUT);
digitalWrite(yellowled, HIGH);
delay (1000);
digitalWrite(yellowled, LOW);
delay (1000);
}

void setup()

{int yellowled = 7;
pinMode (yellowled, OUTPUT);
digitalWrite(yellowled, HIGH);
delay (1000);
digitalWrite(yellowled, LOW);
delay (1000);
}

void setup()

{int yellowled = 8;
pinMode (yellowled, OUTPUT);
digitalWrite(yellowled, HIGH);
delay (1000);
digitalWrite(yellowled, LOW);
delay (1000);
}

void setup()

{int yellowled = 9;
pinMode (yellowled, OUTPUT);
digitalWrite(yellowled, HIGH);
delay (1000);
digitalWrite(yellowled, LOW);
delay (1000);
}

Run "verify" on your program and follow the error code(s).
It is not necessary to set pins to output - it is a default state. Sorry, my error.
Than check the References" -> "control structure " for (...) .
Than if you need more help be more specific with "Subject"
Have fun.

I don't know if you meant to write 8 times the setup() function on your program. You can have only one setup() function.

Try and understand the following:

void setup()
{
   int i;
   /* Setup 8 LEDs and turn them on  */
   for (i = 2; i <= 9; i++)
   {
        pinMode (i, OUTPUT);
        digitalWrite(i, HIGH); 
   }

    delay(1000);

    /* Turn LEDs off */
    for (i = 2; i <= 9; i++)
   {
        digitalWrite(i, LOW); 
   }
}

Hi there,

The thing is, you can only have one instance of setup(), so you can't do it that way. Then, even if you put those bit of code one after the other in the only setup(), you'll find that each piece needs the previous one to finish, which means those delay()s hold things up.

This is a really good time for you to eschew delay() and go straight to Bink Without Delay and you'll probably find this video of use.

It is not necessary to set pins to output - it is a default state.

Rubbish. Pins default to INPUT.

Oops! Corrected the code I posted before. Sorry.