import utime, random
from machine import Pin
button = Pin(16, machine.Pin.OUT)
led = Pin(25, machine.Pin.OUT)
while True:
    button.toggle()
    if button.value()==0:
        led.value(1)
    else:
        led.value(0)
    utime.sleep(1)

一个接电源,一个接GND,一个GPIO