Can i do this? led(i) for Led1, Led2...

I really don’t have much of an idea what to search for as im very new to all this. so i’m sorry if this has been asked alot before.

What i am trying to do is a for loop the leds turn on and of in order, however the pins aren’t connected in order. so i want to use Led where i is a integer that is defined by a for loop.
```
*#define Led1 6
#define Led2 7
#define Led3 8
#define Led4 9
#define Led5 5

void setup() {
  for (int i=4; i<10; i++) {
    pinMode(i, OUTPUT);
  }
}

void loop() {
  for (int i=1; i<=5; i++){
    digitalWrite(Led[i], HIGH);
    delay(50);
  }*
```
Is there a way to do this?

Use an array.

Thanks ^^

something like this.

const byte leds[] = {6, 4, 11, 3, 7, 9}; // the pins connecting to the LEDs in the order you want

const byte nbLeds = sizeof(leds) / sizeof(leds[0]); // this will calculate how many LEDs you have

const unsigned long refreshPeriod = 1000ul;
const unsigned long cycleDelta = 50ul;

void setup() {
  Serial.begin(115200);
  for (int i = 0; i < nbLeds; i++) {
    pinMode(leds[i], OUTPUT);
    digitalWrite(leds[i], LOW);
  }
}

void loop() {
  static unsigned long previousTime;
  static boolean ledsOn = false;

  if (millis() - previousTime >= refreshPeriod) {
    for (int i = 0; i < nbLeds; i++) {
      digitalWrite(leds[i], ledsOn ? LOW : HIGH);
      delay(cycleDelta);
    }
    ledsOn = !ledsOn;
    previousTime += refreshPeriod;
  }
}