// Define the LED pins
const int ledPins[] = {23,22,17,4}; // Pins connected to LEDs
int counter = 15; // Start counter at 15 (maximum for 4-bit)
void setup() {
// Initialize the LED pins as outputs
for (int i = 0; i < 4; i++) {
pinMode(ledPins[i], OUTPUT);
}
}
void loop() {
// Display the current counter value on the LEDs
for (int i = 0; i < 4; i++) {
digitalWrite(ledPins[i], (counter >> i) & 0x01);
}
// Decrement the counter
counter--;
// Reset counter after it reaches -1 (0 to 15 for 4-bit counter)
if (counter < 0) {
counter = 15;
}
// Wait for one second
delay(1000);
}