Raspberry Pi Pico
Raspberry Pi Pico is a low-cost, RP2040 chip-based microcontroller. It has dual-core APR Cortex M0+ processor. Besides, the board has a temperature sensor on-board and 26 multi-function GPIO pins.
Learn More 👉 Raspberry Pi Pico
Steps to use CircuitPython with VS Code
The following steps will help you to write code on Pi Pico using CircuitPython & VS Code.
1. Download and upload CircuitPython
- Download the
.uf2file for Raspberry Pi Pico from Pico Download (circuitpython.org).
- Push and hold the BOOTSEL button on the Pi Pico and plug in the USB cable.
- It will mount the Pico as a mass storage device (RPI-RP2) in the computer.
- Copy the
.uf2file to the RPI-RP2 volume.
Learn More 👉 CircuitPython
2. Download VS Code and install CircuitPython extension
- Download VS code from Visual Studio Code.
- Install the
CircuitPythonextension by joedevivo from VS Code Marketplace.
3. Write Code
- Open a new directory in VS Code.
- Open command palette and select
CircuitPython: Select Serial Port.
- Select the COM port of your Pi Pico. (For example,
- Create a python file in the root directory. (For example,
- Write your code in the file.
The following code sample will blink the LED on the Pi Pico board.
# build-in LED blink in Pi Pico using CircuitPython import time import board import digitalio led = digitalio.DigitalInOut(board.LED) led.direction = digitalio.Direction.OUTPUT # set the direction of the pin while True: led.value = True # turn the LED on time.sleep(0.5) # wait for 0.5 seconds led.value = False # turn the LED off time.sleep(0.5) # wait for 0.5 seconds
4. Upload code to Pi Pico
- If you are using Windows, open a new terminal and run the following command.
$currDir = Get-Location $targetDir = "E:" Remove-Item $targetDir* -Recurse -Force Copy-Item $currDir* $targetDir -Recurse -Force
- If you are using Linux, open a new terminal and run the following command.
cp -r * /media/$USER/RPI-RP2
- "Raspberry Pi Documentation - Raspberry Pi Pico and Pico W" Raspberrypi, https://www.raspberrypi.com/documentation/microcontrollers/raspberry-pi-pico.html.
- "CircuitPython" Circuitpython, https://circuitpython.org/.