MicroPython: button and LED
A button on GP14 toggles an LED on GP15 through an interrupt.

The code
# A button on GP14 (to ground, the pull-up inside) toggles the LED on GP15, through an
# interrupt. Click the button while it runs.
from machine import Pin
import time
led = Pin(15, Pin.OUT)
button = Pin(14, Pin.IN, Pin.PULL_UP)
presses = 0
def pressed(pin):
global presses
presses += 1
led.toggle()
button.irq(trigger=Pin.IRQ_FALLING, handler=pressed)
while True:
print("presses:", presses)
time.sleep(1)
More like this

MicroPython: blink
MicroPython’s own firmware on the real RP2040: the LED blinks, the board prints. No build.
MicroPythonRaspberry Pi Pico

MicroPython: knob dimmer
A potentiometer on GP26 sets an LED’s brightness on GP15 with PWM.
MicroPythonRaspberry Pi Pico

Pico: blink and breathe
The Pico’s own LED blinks, an LED on GP15 breathes with PWM, the knob on GP26 sets the pace.
ArduinoRaspberry Pi Pico