Raspberry Pi Pico Getting Started Guide (2024)

If you've just bought your very first Raspberry Pi Pico (or perhaps our superb Raspberry Pi Pico Starter Kit), this easy-to-follow tutorial will help you to get you up and running.

We'll show you around the Raspberry Pi Pico and its various features then explain how to set up popular software to allow you to start coding, with a couple of simple projects to get you started too!

Ready? Let's go!

Parts Required

The minimum setup to get started requires a Raspberry Pi Pico and a Micro-USB cable:

Raspberry Pi Pico

No surprises here - you're going to need a Raspberry Pi Pico! At the time of writing there are three versions of the Pico available, however we recommend the Pico H variant as this comes with pre-soldered headers.

We don't recommended that beginners start with the Raspberry Pi Pico W as you likely won't make use of thewireless features until later down the line.

Our Raspberry Pi Pi Pico Starter Kit includes a Pico H, or grab a board from the links below:

  • Raspberry Pi Pico
  • Raspberry Pi Pico H
  • Raspberry Pi Pico W

Micro-USB Cable

You'll need a Micro-USB cable to allow your Raspberry Pi Pico to talk to your computer for programming, as well as providing power.

Our Raspberry Pi Pi Pico Starter Kit includes a micro-USB cable, however if you're buying parts separately, you can grab one here.

Optional parts

We're going tobe lighting up someLEDs using code as a little starter project. If you've got our starter kit you'll have all the bits you need, however if you're buying parts individually you may need the following items if you want to follow along (many existing makers may already own similar items):

  • Breadboard (at least 400-point/half-size)
  • 5mm LEDs (300-piece LED kit / Handy 25-pack / Affordable 10-pack)
  • 330 ohm resistors (Resistor Kit / Individual pack)
  • Jumper wires (Full 120-piece pack / 20-pack)

What is a Raspberry Pi Pico?

The Raspberry Pi Pico is a powerful, flexible microcontroller board from Raspberry Pi - the same nice folks who brought us theRaspberry Pi 4andRaspberry Pi Zero.

The Raspberry Pi Pico is a differentkind of Raspberry Pi though - it's a microcontrollerboard, not a microcomputer.The brain of the Pico is the RP2040 microcontroller chip, the little black square in the middle.

Whereas you might use a Raspberry Pi 4 (which has an operating system) to play games, write stories and browse the web, the Raspberry Pi Pico is designed for physical computing projects where it can control components such as LEDs, buttons, sensors, motors and even other microcontrollers.

Raspberry Pi Pico Getting Started Guide (1)

Raspberry Pi Pico Board Features

The Raspberry Pi Pico is pretty tiny, coming in at just 51mm x 21mm - great for embedding into small projects!

One end of the board has a Micro-USB port which, when used with a USB cable, powers the board and allows it to communicate to our computer for programming. The other end has a debug port for debugging (something beginners really won't need to worry about just yet!).

In the middle is the RP2040 chip (the black square) - this is the brains of our board and the first microcontroller chip produced by Raspberry Pi themselves!

All around both sides you'll see lots of pins...so let's talk about those for a moment as you'll be using these a LOT!

Raspberry Pi Pico Getting Started Guide (2)

Raspberry Pi Pico GPIO Pins

The board has lots of pins around it called GPIO (GeneralPurposeInputOutput) pins, which allow you to connect all sorts of components to make projects. These are controlled by code that you write.

A complete map of the Pico H's physical pins is available here. You'll noticelots of labels in lots of different colours, but let's just talk about the main ones you'll be interested in as a new user:

  • Light green - These the the basic GPIO pins. We use these to communicate with components such as sensors or LEDs either as an input or an output
  • Red - These are your power pins. You'll mostly be using 3V3(OUT) as this provides 3.3V for powering sensors and other parts
  • Black - These are your Ground (GND) pins

There are lots of other pin functions available which are represented by the other colours, but let's not worry about those just yet as beginners.

Here's a much simpler version of the Pico pin map with the main pins we're interested in for now:

Raspberry Pi Pico Getting Started Guide (3)

Raspberry Pi Pico Programming Languages

The Raspberry Pi Pico canuse a range of popular programming languages such as C/C++/Arduino and CircuitPython, however the most popular is arguably MicroPython. You'll find the majority of projects and examples on the internet use MicroPython.

MicroPythonis an smaller, more efficient version of the Python 3 programming language, designed to be used with microcontroller boards such as the Raspberry Pi Pico. If you've programmed with Python previously, MicroPython will feel very familiar.

Raspberry Pi Pico Setup

Now that we know what the Pico is and how it works, let's get yours set up, running and ready to code! To do this we'll need to download and install some software...

Note: this tutorial is based on using Windows 10/11. This may differ for those using older versions or MacOS. The software we're using is not currently available for Chromebooks (well, not without a lot of messing around at least!)

Software Setup

We’re going to install software called Thonny, which will allow us to program the Pico with MicroPython.

Thonny is a Python IDE. An IDE is an Integrated Development Environment. IDEs help us to write code by giving us lots of helpful features to avoid errors, make our code more readable and lots of other benefits.

So, let's get Thonny! Head over to https://thonny.org/ and look for this little box:

Raspberry Pi Pico Getting Started Guide (4)

If you hover over the name of the operating system you’re usingyou should see some options, with a recommended option based on the system you’re using. For us, using a 64-bit version of Windows, it’s recommending the 64-bit version.

Your system may be different, so it’s best to just go with the version the website recommends:

Raspberry Pi Pico Getting Started Guide (5)

Download the correct version for your computer then open the file to start the installation.

Thonny installs like most programs, and will ask you to accept the license agreement and confirm where to install it. We kept all the options as default and it took just under a minute to install.

Once installed, select ‘Finish’ and then open the program. In Windows 10/11 you can select the Windows Start button and just type in ‘Thonny’. The program should open and look like the example below:

Raspberry Pi Pico Getting Started Guide (6)

Install MicroPython on the Raspberry Pi Pico

We now need to install the MicroPython firmware on the Raspberry Pi Pico. This gives the Pico the basic software it needs to run MicroPython code that we'll send to it later.

Important Note: You mayexperience an issue when using the method we have suggested below (SSL errors for example). Give it a try, but if you have trouble installing MicroPython on your Pico, try the other method here instead.

First, plug your Micro-USB cable into the Pico - but don't plug it into your computer yet!

Now locate the little button on top of your Pico. This is the ‘BOOTSEL’ button which, when held in whilst connecting the cable, allows us to install firmware to the Pico.

Raspberry Pi Pico Getting Started Guide (7)

Hold down that button whilst plugging in the USB cable into your computer’s USB port at the same time. You may see it pop up as a new device on your computer but just ignore that for now.

In Thonny, at the bottom-right-hand corner, you should see something like 'MicroPython (Raspberry Pi Pico)' and a COM port, like the example below (this may vary but it doesn’t matter at this stage). Click on this and you’ll see a few options. Select ‘Install MicroPython…’

Raspberry Pi Pico Getting Started Guide (8)

You’ll now be presented with some options in a new dialogue box. Use the same options as per the screenshot below, selecting the RPI-RP2 target volume, Raspberry Pi Pico / Pico H variant, and whatever the latest version is available (at the time of writing it was 1.19.1):

Raspberry Pi Pico Getting Started Guide (9)

Select ‘Install’ and you’ll see a small progress bar whilst it installs. Once complete, select ‘Close’.

Setting up Thonny

Thonny can be used with a range of development boards, so we need to tell Thonny that we are using a Raspberry Pi Pico.

From the top menu, select ‘Run’ then ‘Configure interpreter’:

Raspberry Pi Pico Getting Started Guide (10)

Now just make sure that ‘MicroPython (Raspberry Pi Pico)' is selected in the first drop-down box, select the available device in the ‘Port’ drop-down, then select ‘OK’.

Tip: If you see multiple options in the Port drop-down box, it just means you have other devices connected to your computer. If you’re not sure which one is the Pico, make a note of what COM ports are showing, disconnect the Pico from the USB port, close the Thonny options box, then try again. Whichever one is now missing was the Pico, so connect it again and select that device next time (it’s a lot easier than disconnecting everything else if you have lots of other devices!)

You should now see a ‘Raspberry Pi Pico’ panel on the left-side of Thonny, and information in the bottom-right 'Shell' panel.

Tip: If you don't see your Pico on the left, try selecting 'View' from the top navigation bar, and selecting 'Files'.

Raspberry Pi Pico Getting Started Guide (11)

That’s the setup out of the way, we’re ready to code!

Your First Raspberry Pi Pico Program!

Let’s make a very simple program and run it on your Pico.

We’ll tell the Pico to ‘print’ some words (known as a'string' of text). These words/strings are then 'printed' to the Shell window (the bottom right panel).

The print function is something you’ll use a LOT when programming. It’s a useful tool to see what’s happening with a program, what part of aprogram is running and can help when debugging projects.

In the top panel (which should be called <untitled> at the moment as we haven'tsaved it yet), copy/paste or type in enter the following line and then select the green run icon (itlooks like a ‘Play’ button) from the menu.

print("This is my Pico talking")

You should now see the following in the Shell window:

Raspberry Pi Pico Getting Started Guide (12)

You did it! Your first program!

A few things to note:

  • Print text strings always sit within inverted commas, within brackets (or parenthesis)
  • Letter case is very important with MicroPython and other code languages. Our print is always 'print' and never 'Print'.

Now try changing the text in between the inverted commas - you can write anything you want (why not try the classic "Hello World"?). You can even add multiple print lines one after the other - give it a try!

Light the Pico's Onboard LED

We now know where to write code in Thonny and how to run a program, so let's jump straight into a bit of LED control!

The Pico comes with a little LED onboard, which is attached to one of the RP2040 pins, GPIO25. This pin isn't one of the physical pins available around the edge of the board.

Note: the Pico W has a slightly different pin setup as it uses a GPIO pin on the wireless chip to control the onboard LED. We'll show you how to do this on both boards below.

We can tell our program to turn this pin on and off whenever we like, which is a nice easy first hardware project and can be handy as an indicator for your own projects later on.

Raspberry Pi Pico Getting Started Guide (13)

Inputs and outputs

Our GPIO pins (the green ones from the pin map) can be set as inputsor outputs. We use inputs when we want something to send signals/voltage into the Pico, like a button or a sensor, and we useoutputs when we want the Pico to send signals/voltage outto something else, like LEDs or buzzers.

We’re going to use an output here, which will send voltage to the onboard LED to light it up.

Imports

Take a quick glance at the first line of the example code below. When we write code in Thonny, a lot of the time we need to add importsat the start.

Imports bring in code from other places (called 'modules' or 'classes' ) that we need to make our program work. Usually these are from built-in modules.

To use the GPIO pins, we always need to import Pin.

The Code - Pico/Pico H version

Take another look at the example below. So, what is it doing?

  • The first line imports ‘Pin’ from the 'machine' module on the first line, which simply allows us to use the GPIO pins.
  • The second line is setting up one of the pins to allow us to use it in our code. This sets up GPIO25with the name ‘onboardLED’. We use Pin.OUT at the end there to tell MicroPython to set this pin as an output.
  • The third line then finally sets that pin value to ‘1’ which is HIGH (on). 1 is always used for HIGH (on) and 0 is used for LOW (off).
from machine import PinonboardLED = Pin(25, Pin.OUT)onboardLED.value(1)

Copy that code to your top-right panel, then hit the run button. The LED should light up – hooray – you’ve controlled your first physical component!

Now try changing the 1 to a 0 - run the code again and it should turn the LED off.

The Code - Pico W version

If you want to do the same with a wireless-enabled Raspberry Pi Pico W, just change the pin number (25) to 'LED' (including the quotation marks), like this:

from machine import PinonboardLED = Pin('LED', Pin.OUT)onboardLED.value(1)

Light LEDs with the Raspberry Pi Pico

We've mastered the onboard LEDs, so let's now set up a circuit with the LEDs in your starter kit. We'll show you how to wire the circuit and control them with code on your Pico.

First,make sure your Pico is disconnected from the USB cable. You should always do this when amending a circuit.

Breadboards

We're going to be adding components to ourbreadboard. Breadboards allow you to connect and prototype a circuit without soldering, using wires with pins at the end called jumper wires (sometimes called DuPont wires).

These breadboards have two sets of horizontal channels (red/blue) on both sides. All the red pins are connected, as are the blue (but each side is disconnected from the other). We use these to create 'rails' of connections for us to use, such as Ground (GND) for the blue channel and 3.3V for the red.

The holes in the middle are connected in verticallanes, with each lane having 5 connected pins either side of the divider. The divider stopsboth sides connecting together.

Push your Raspberry Pi Pico fully into your breadboard (so that you can't see the metal pins anymore) as per the image below.

Raspberry Pi Pico Getting Started Guide (14)

Raspberry Pi Pico LED Circuit

Place the three LEDs into the lower section of the breadboard, 1 hole apart, with the longest leg to the rightas seen in the image below.

You won't know which colour is which yet as our kit's LEDs have clear lenses, but that doesn't matter and we'll come back that in a moment. Your breadboard should look like this:

Raspberry Pi Pico Getting Started Guide (15)

Tip: The short leg is the Cathode (-) and the long leg is the Anode (+).

We now need to add a resistor to limit the current that the LED can draw from our GPIO pins.

Place a resistor between the left leg of each LED and the lower blue channel, like below. We'll be connecting that blue channel to a Ground (-) pin shortly.

Raspberry Pi Pico Getting Started Guide (16)

Now grab your stash of jumper wires. You need one wire connecting the blue channel to a Ground pin on your Pico – we suggest usingphysical pin 38like we’ve done in the diagram below (remember to refer to the Pico pinout if you need a reminder).

You also need to connect the right leg of each LED leg to a GPIO pin. Use GPIO18 (physical pin 24) for Red, GPIO19 (physicalpin 25) for Amber, and GPIO20 (physicalpin 26) for Green, like the diagram below.

Tip: It doesn't matter what colour jumper wires you use, they all work the same way. In an ideal world we would reserve black for ground connections and red for voltage, but for simple projects it's not essential.

Raspberry Pi Pico Getting Started Guide (17)

Simple LED Project

We're going to show you a simple bit of code to light each of the LEDs in your kit just to get you started. We’re going to light each LED, wait 5 seconds, then turn them off.To do this we need to use the time module.

The Time Module

The time module allows you to program delays in your code, making it wait for seconds or fractions of seconds before continuing. It’s a fundamental module you’ll use in most of your projects.

The Code

Our code imports pinand also imports time. We then define the pin number for each colour of LED (giving them a sensible name for each) and set them to outputs.

After that it’s a simple case of setting each LED pin HIGH, waiting for 5 seconds using time.sleep(5), then setting them all LOW again.

Here’s the code to copy into Thonny and then run it by hitting the green button:

from machine import Pinimport timeled1 = Pin(18, Pin.OUT)led2 = Pin(19, Pin.OUT)led3 = Pin(20, Pin.OUT)led1.value(1)led2.value(1)led3.value(1)time.sleep(5)led1.value(0)led2.value(0)led3.value(0)

Over to you!

    The wonderful world of coding, making, projects and, of course, the Raspberry Pi Pico awaits you!

    Be sure to check out the Raspberry Pi website for projects and inspiration, the Raspberry Pi forum Pico section for troubleshooting and ideas, social network user groups for inspiration and support and, as always, search engines are your friend!

    Don't forget to also check out our dedicated Raspberry Pi Pico section in the store, full of handy accessories, add-ons, books and more!

    We usedFritzingto create the breadboard wiring diagram image

    Raspberry Pi Pico Getting Started Guide (2024)

    FAQs

    Raspberry Pi Pico Getting Started Guide? ›

    Hold down the BOOTSEL button on your Raspberry Pi Pico W. Connect the other end to your desktop computer, laptop, or Raspberry Pi. Your file manager should open up, with Raspberry Pi Pico being show as an externally connected drive. Drag and drop the firmware file you downloaded into the file manager.

    What to do when you first get a Raspberry Pi? ›

    Booting Your Raspberry Pi for the First Time
    1. Insert the microSD card into the Raspberry Pi.
    2. Connect the Raspberry Pi to a monitor, keyboard and mouse.
    3. Connect an Ethernet cable if you plan to use wired Internet.
    4. Plug the Pi in to power it on.
    Sep 21, 2022

    How do I set up and program my Raspberry Pi Pico? ›

    Hold down the BOOTSEL button on your Raspberry Pi Pico W. Connect the other end to your desktop computer, laptop, or Raspberry Pi. Your file manager should open up, with Raspberry Pi Pico being show as an externally connected drive. Drag and drop the firmware file you downloaded into the file manager.

    Which programming language is best for Pi Pico? ›

    The Raspberry Pi Pico can use a range of popular programming languages such as C/C++/Arduino and CircuitPython, however the most popular is arguably MicroPython. You'll find the majority of projects and examples on the internet use MicroPython.

    Can Raspberry Pi Pico run independently? ›

    Powering your Pico

    If you want to run your Raspberry Pi Pico without it being attached to a computer, you need to use a USB power supply or a suitable battery pack and connectors. Safe operating voltages are between 1.8V and 5.5V.

    How to setup Raspberry Pi step by step? ›

    1. Setting up your Raspberry Pi. Connecting a Display. SD Cards for Raspberry Pi. Optional items. Troubleshooting.
    2. Installing the Operating System. Using Raspberry Pi Imager. Downloading an Image.
    3. Installing over the Network. Using Network Installation.
    4. Configuration on First Boot.

    Can Raspberry Pi Pico be used as a computer? ›

    The Pico is not a computer, rather we need to write code in an external application on a different computer and “flash” the code to the microcontroller over USB. In our tutorial on how to get started with Raspberry Pi Pico, we explain how to connect a PC to the Pico and use it to upload MicroPython code.

    Can I run Python on Raspberry Pi Pico? ›

    You can develop Python scripts that will be directly executed on a Raspberry Pi Pico board or an ESP32. To do this, we install MicroPython on the board and then use software (Thonny IDE, for example) to write the Python script and send it to the board.

    What to buy to get started with Raspberry Pi? ›

    Here is everything you will need to turn your Raspberry Pi into a desktop computer:
    1. Power supply.
    2. MicroSD card.
    3. HDMI cable.
    4. Monitor (a TV will work)
    5. Keyboard.
    6. Mouse.
    Jan 6, 2023

    What IDE is used for Raspberry Pi Pico? ›

    It is now possible to program the Raspberry Pi Pico board with Arduino code directly from the Arduino IDE. Adding the support is similar to installing the ESP32 boards via the additional board manager via the Arduino IDE.

    How to run Raspberry Pi Pico without computer? ›

    If you want to run your Raspberry Pi Pico without it being attached to a computer, you need to use a USB power supply. Safe operating voltages are between 1.8V and 5.5V. In Thonny, click on the File menu and then Save as for the last program you wrote.

    Top Articles
    Latest Posts
    Recommended Articles
    Article information

    Author: Merrill Bechtelar CPA

    Last Updated:

    Views: 6165

    Rating: 5 / 5 (70 voted)

    Reviews: 85% of readers found this page helpful

    Author information

    Name: Merrill Bechtelar CPA

    Birthday: 1996-05-19

    Address: Apt. 114 873 White Lodge, Libbyfurt, CA 93006

    Phone: +5983010455207

    Job: Legacy Representative

    Hobby: Blacksmithing, Urban exploration, Sudoku, Slacklining, Creative writing, Community, Letterboxing

    Introduction: My name is Merrill Bechtelar CPA, I am a clean, agreeable, glorious, magnificent, witty, enchanting, comfortable person who loves writing and wants to share my knowledge and understanding with you.