🛠 Faire clignoter la LED embarquée

Raspberry Pi Pico 2 · debutant · Schéma : IMG-pico-2-debutant-1-pico2-blink-led.svg — Raspberry Pi Pico 2 vue de dessus avec la LED utilisateur GP25 mise en évidence et le bouton BOOTSEL

Objectives

Discover the Raspberry Pi Pico 2, its RP2350 SoC (2 Arm Cortex-M33 cores up to 150 MHz, 520 KB of RAM, 4 MB of QSPI flash), and implement your first C/C++ program with the Pico SDK. By the end, the onboard user LED will blink, and you will know how to compile and flash a .uf2 file.

Hardware

Complete code

/* blink.c — Pico 2 : LED utilisateur sur GP25 (définie par boards/pico2.h) */
#include "pico/stdlib.h"

#define LED_PIN 25   /* GP25 = LED utilisateur sur Pico 2 (confirmé datasheet) */

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);
    }
}

Compilation: cmake -B build -DPICO_BOARD=pico2 .. then cmake --build build. Hold down BOOTSEL, plug in the USB, and copy blink.uf2 to the RPI-RP2 drive.

Expected verification

The LED blinks: on for 250 ms, off for 750 ms. The RPI-RP2 drive appears only when BOOTSEL is held down during connection; after copying the .uf2, the board restarts automatically and the program runs without a serial cable.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials