🛠 Faire clignoter la LED embarquée
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
- 1 × Raspberry Pi Pico 2 (ref. SC1631, or SC1632 with male headers)
- 1 × micro-USB data cable
- PC with Pico SDK ≥ 2.0.0 (the first version supporting the RP2350) and the arm-none-eabi-gcc toolchain
- Software: no driver required on Windows for BOOTSEL mode
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
- Forgetting
-DPICO_BOARD=pico2: the SDK then targets pico (RP2040) and the binary does not work correctly. - Using a charge-only micro-USB cable: no USB enumeration, the RPI-RP2 drive never appears.
- A MicroPython/CircuitPython .uf2 for RP2040 will not flash: specific RP2350 firmware is required (MicroPython ≥ 1.24.0).
- Confusing GP25 (LED) with a free pin: on both Pico 2 and Pico 1, GP25 is internally wired to the LED.
Other tutorials for this board
Code examples for this board
clignotante.pyPythonbouton-interruption.pyPythonpwm-servo.pyPythonlecture-adc.pyPythonneopixel.pyPythonoled-i2c.pyPython