from machine import Pin import time # Initialize pins using actual GPIO numbers # D2 is GPIO4 (Button), D3 is GPIO5 (LED) button = Pin(4, Pin.IN, Pin.PULL_UP) led = Pin(5, Pin.OUT) print("Starting MicroPython Button Test...") while True: # Read button state (1 = unpressed, 0 = pressed due to PULL_UP) button_state = button.value() print("Button State:", button_state) if button_state == 1: led.value(1) # Turn LED on when not pressed else: led.value(0) # Turn LED off when pressed time.sleep(1) # Delay to match the Arduino sketch