from machine import Pin
import time
# Define GPIO pins for 4 LEDs (adjust to your wiring)
led_pins = [10, 11, 12, 13] # Example pins GP2–GP5
leds = [Pin(pin, Pin.OUT) for pin in led_pins]
def display_binary(value):
"""Show a 4-bit binary number on LEDs"""
for i in range(4):
bit = (value >> i) & 1
leds[i].value(bit)
# Binary counter loop
counter = 0
while True:
display_binary(counter)
time.sleep(1) # 1 second delay between counts
counter = (counter + 1) % 16 # wrap around after 15