🛠 Faire clignoter la LED embarquée via la radio

Raspberry Pi Pico 2 W · debutant · Schéma : IMG-pico-2-w-debutant-1-pico2w-clignoter-led-embarquee.svg — Raspberry Pi Pico 2 W vue de dessus, puce radio CYW43439 surlignée, LED embarquée et flèche vers le port micro-USB.

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

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

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials