const int ledPins[5] = {2, 3, 4, 5, 6}; // LED pins
int count = 0; // Start count at 0
void setup() {
for (int i = 0; i < 5; i++) {
pinMode(ledPins[i], OUTPUT);
}
}
void loop() {
for (int i = 0; i < 5; i++) {
digitalWrite(ledPins[i], bitRead(count, i)); // Set LEDs according to binary value
}
count++; // Increment count
if (count > 31) count = 0; // Reset after reaching 31
delay(500); // Wait 500ms
}