Blinky with RaspberryPI Pico

Updated on 2 November 2022
dev board RaspberryPI Pico
firmware C
firmware C++
chip RP2040
This tutorial is more than 1 year old. If the steps below do not work, then please check the latest versions and the documentations of the individual tools used.

Before starting

Dependancies

Ensure the following dependancies are downloaded and available:

Buy the components

Code

Download code blinky-pico.c
#include <stdio.h>
#include "pico/stdlib.h"

const uint LED_PIN = 25;

int main() {
  stdio_init_all();

  gpio_init(LED_PIN);
  gpio_set_dir(LED_PIN, GPIO_OUT);

  while (true) {
    gpio_put(LED_PIN, 0);
    sleep_ms(250);
    gpio_put(LED_PIN, 1);
    puts("Hello World blinky!");
    sleep_ms(1000);
  }
}

Prototype

A photo of the actual setup.

Blinky with RaspberryPI Pico prototype

Serial console

Serial output from the firmware.

Blinky with RaspberryPI Pico serial console

Description

Create a blinky LED with RaspberryPI Pico board with RP2040 microcontroller using the native C/C++ SDK.

Install the toolchain on macOS

Refer Getting started with Raspberry Pi Pico PDF document for Linux or Windows.

cd CHOOSE_YOUR_PICO_SDK_PATH
git clone [email protected]:raspberrypi/pico-sdk.git

brew install cmake
brew tap ArmMbed/homebrew-formulae
brew install arm-none-eabi-gcc

# vs code extensions
code --install-extension marus25.cortex-debug
code --install-extension ms-vscode.cmake-tools
code --install-extension ms-vscode.cpptools

# environment variable for the pico-sdk installation apth
export PICO_SDK_PATH=~/PATH/TO/pico-sdk

References

Watch