How To Write Code on Pi Pico using CircuitPython & VS Code?

Easily write code on Raspberry Pi Pico using CircuitPython with VS Code.
featured image
Tasnim Zotder
Nov 4, 2021
⏱️ 2 Minutes

Pi Pico

Raspberry Pi Pico is a low-cost, RP2040 chip-based microcontroller. It has dual-core ARM Cortex M0+ processor. Besides, the board has a temperature sensor on-board and 26 multi-function GPIO Pins.

Learn more 👉 Raspberry Pi Documentation - Raspberry Pi Pico

Pi Pico Pinout


1. Download CircuitPython `.uf2` File and Upload to Pi Pico

  1. Go to the website 👉 Pico Download ( and download the `.uf2` file for Raspberry Pi Pico.
  2. Push and hold the BOOTSEL button and plug the USB into the Pi Pico.
  3. It will mount as a Mass Storage Device called RPI-RP2.
  4. Drag-n-drop the CircuitPython .uf2 file onto the RPI-RP2 volume. This will reboot the Pi Pico.

Learn more about CircuitPython 👉 CircuitPython

connect Pi Pico

2. Download VS Code and CircuitPython Extension

  1. Download & install VS Code from here 👉 Visual Studio Code - Code Editing. Redefined
  2. Install the CircuitPython extension by joedevivo 👉 CircuitPython - Visual Studio Marketplace
CircuitPython demo

3. Write Code

  1. Open a directory in VS Code.
  2. Open Command Palette and type CircuitPython: Select Serial Port
  3. Select the COM port with Raspberry Pi: Pico
  4. create a python file in the root directory. e.g.
  5. Write on-board LED blink code -
# 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 Poco

Here, E: is the Pi Pico mounted drive. Change it according to your system.
$currDir = Get-Location
$targetDir = "E:"

Remove-Item $targetDir\* -Recurse -Force
Copy-Item $currDir\* $targetDir\ -Recurse -Force

💡 Pro Tip

To directly use pico upload and pico download from the terminal (windows only), add the following PowerShell script to the profile.ps1 file of your terminal.

function pico {
    param (
        [Parameter(Mandatory = $true)]

    if ($value -eq "upload") {
        $currDir = Get-Location
        $targetDir = "E:"

        Remove-Item $targetDir\* -Recurse -Force
        Copy-Item $currDir\* $targetDir\ -Recurse -Force
    elseif ($value -eq "download") {
        $currDir = "E:\"
        $targetDir = Get-Location

        Copy-Item $currDir* $targetDir\ -Recurse -Force

References 📝

  • Blog
  • YouTube
  • Portfolio

© Tasnim Zotder | 2022