🛠 Faire clignoter la LED embarquée (GP25)
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
- 1 × Raspberry Pi Pico (or Pico H with soldered headers)
- 1 × micro-USB data cable (some cables only provide charging)
- PC with the Pico SDK (gcc-arm-none-eabi + CMake ≥ 3.13),
PICO_SDK_PATHvariable defined
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
- Wrong pin number: on the classic Pico, the LED is indeed on GP25 (confirmed by the datasheet), not GP2 as on other boards.
- Forgetting
gpio_set_dir(..., GPIO_OUT): the pin remains an input, nothing blinks. - Charge-only USB cable: the board never appears on the PC.
PICO_SDK_PATHnot defined: CMake fails atinclude(pico_sdk_import.cmake).- The
.uf2file does not appear: recompile, or check thatpico_add_extra_outputsis indeed called.
Other tutorials for this board
Code examples for this board
clignotante.pyPythonbouton-interruption.pyPythonpwm-servo.pyPythonlecture-adc.pyPythonneopixel.pyPythonoled-i2c.pyPython