Tutorial: Hello LED (EduRP2040)
Blink the RP2040 on-board LED using MicroPython.
Requirements
- EduRP2040 with MicroPython installed (see Quick start)
- Thonny editor
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
- Plug the board over USB.
- Open Thonny and select MicroPython (Raspberry Pi Pico) interpreter.
- 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.