Why do I need this?

why do I need to use the "int" again on counterLED below void loop, if I had already used it in void setup? It says that counterLED wasnt enabled in this scope, but I thought the int counterLED inside the for loop at void setup would have done the job.

I fattened the code that Im trying to understand.

The code:
int counter;
int delay1 = 666;


void setup() {
  • this is the first time is use int*
    for(int counterLED=2;counterLED<=6;counterLED++) {
    pinMode(counterLED, OUTPUT);
    }
    Serial.begin(9600);
    }
void loop() {
  • why is the int needed here again for the same variable?*
    for (int counterLED=2; counterLED<=6;counterLED++) {
    digitalWrite(counterLED, HIGH);
    delay(delay1);
    digitalWrite(counterLED, LOW);
    }
thanks a lot
Was this page helpful?