Free online Pi Pico simulator projects - Blink an LED

Story

In this project, you will learn how to program Pi Pico to blink its onboard LED. we'll use a free Pi Pico simulator from Wokwi. The home page of Wokwi is here: https://wokwi.com

Connection diagram

No connections are necessary. Onboard LED will be blinked.

Code


/**
 * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include "pico/stdlib.h"

void setup() {
#ifndef PICO_DEFAULT_LED_PIN
#warning blink example requires a board with a regular LED
#else
    const uint LED_PIN = PICO_DEFAULT_LED_PIN;
    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(250);
    }
#endif
}

void loop() {}

 Simulation

Support/feedback

Please hop on to https://wokwi.com/discord for any questions or feedback related to the simulation or projects in general.