Tutorial: Hello LED (EduRP2040)

Blink the RP2040 on-board LED using MicroPython.

Requirements

Code

# main.py
from machine import Pin
from time import sleep

led = Pin(25, Pin.OUT)   # On-board LED on GP25

while True:
    led.toggle()
    sleep(0.5)

How to run

  1. Plug the board over USB.
  2. Open Thonny and select MicroPython (Raspberry Pi Pico) interpreter.
  3. Paste the code and hit Run (F5).

The LED should blink at 1 Hz.

C/C++ variant (Pico SDK)

#include "pico/stdlib.h"
int main() {
    gpio_init(25);
    gpio_set_dir(25, GPIO_OUT);
    while (true) {
        gpio_put(25, 1); sleep_ms(500);
        gpio_put(25, 0); sleep_ms(500);
    }
}

Next step

Continue with Tutorial: Hello UART.

Comments

...