const int ledPins[] = {18, 19, 21, 22}; // LED pins
int counter = 0;
void setup() {
// Initialize the LED pins as outputs
for (int i = 0; i < 4; i++) {
pinMode(ledPins[i], OUTPUT);
}
}
void loop() {
// Display the counter value on the LEDs
for (int i = 0; i < 4; i++) {
digitalWrite(ledPins[i], (counter >> i) & 1);
}
// Increment the counter
counter++;
if (counter > 15) { // Reset the counter after 15 (4-bit counter)
counter = 0;
}
delay(1000); // Wait for 1 second
}