🛠 Faire clignoter la LED embarquée (GP25)

Raspberry Pi Pico · debutant · Schéma : IMG-pico-debutant-1-pico-blink-led.svg — Raspberry Pi Pico vue de dessus avec la LED embarquée GP25 mise en évidence et le câble micro-USB branché

Objectives

Discover the Raspberry Pi Pico (RP2040: dual-core ARM Cortex-M0+ at 133 MHz, 264 KB of RAM, 2 MB of external QSPI flash) by making its onboard LED blink, controlled by pin GP25. By the end of this tutorial, you will know how to compile a C program with the Pico SDK, produce a .uf2 file, and flash it via drag-and-drop using the USB BOOTSEL bootloader.

Hardware

Complete Code

// blink.c — LED embarquée sur GP25 (Pico datasheet §1)
#include "pico/stdlib.h"

#define LED_PIN 25

int main(void) {
    gpio_init(LED_PIN);
    gpio_set_dir(LED_PIN, GPIO_OUT);
    while (true) {
        gpio_put(LED_PIN, 1);
        sleep_ms(250);
        gpio_put(LED_PIN, 0);
        sleep_ms(750);
    }
}

Compile with CMake (pico_add_extra_outputs(blink) produces the .uf2), then hold down BOOTSEL while plugging in the USB: the board appears as a RPI-RP2 drive, drop the .uf2 file onto it.

Expected Verification

The green LED blinks in a loop: on for 250 ms, off for 750 ms. All GPIOs on the Pico use 3.3 V logic and do not tolerate 5 V — this is a golden rule for what follows.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials