🛠 Faire clignoter la LED embarquée via la radio
Objectives
On the Pico 2 W, the onboard LED is not connected to the RP2350 but to the CYW4343 radio chip (pin WL_GPIO0). This tutorial teaches you how to make it blink using the cyw43_arch API from the pico-sdk, how to compile with the flag PICO_BOARD=pico2_w, and how to flash a UF2 file in BOOTSEL mode.
Hardware
- Raspberry Pi Pico 2 W board
- Micro-USB data cable (not just charging)
- PC with pico-sdk, CMake >= 3.13, and gcc-arm-none-eabi
Complete Code
// main.c - pico-examples pico_w/wifi/blink/picow_blink.c
#include "pico/stdlib.h"
#include "pico/cyw43_arch.h"
int main {
stdio_init_all;
if (cyw43_arch_init) { // alimente et initialise le CYW43
printf("Wi-Fi init failed\n");
return -1;
}
while (true) {
// SURTOUT PAS gpio_put(25, ...) : GP25 est le CS SPI de la radio !
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 1);
sleep_ms(250);
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 0);
sleep_ms(250);
}
}
Compilation: cmake -DPICO_BOARD=pico2_w .. then picobuild blink_led. Hold BOOTSEL, plug in the USB, and copy blink_led.uf2 to the RPI-RP2 drive.
Expected Verification
The onboard LED blinks every 250 ms upon power-up. Without cyw43_arch_init, nothing lights up; if radio initialization fails, the message Wi-Fi init failed appears on the serial console at 115200 baud.
Common Errors
- Using gpio_put(25, ...) inherited from the classic Pico: GP25 is the CYW43 SPI CS line, which corrupts the radio and breaks Wi-Fi.
- Forgetting -DPICO_BOARD=pico2_w: cyw43_arch is not compiled, resulting in a linker error.
- Calling cyw43_arch_gpio_put without a prior cyw43_arch_init.
- Using a charge-only USB cable or releasing BOOTSEL too early: the RPI-RP2 drive never appears.
Other tutorials for this board
Code examples for this board
clignotante.pyPythonbouton-interruption.pyPythonpwm-servo.pyPythonlecture-adc.pyPythonneopixel.pyPythonoled-i2c.pyPython