Function: what a Raspberry Pi Pico does in a circuit
A small, low-cost microcontroller board built around the RP2040 chip. It runs one program, in MicroPython or Arduino C++, as soon as it has power.
- Runs one MicroPython or Arduino program as soon as it has power
- Reads three analog inputs and makes PWM on any pin
- Controls LEDs, sensors and small motors at 3.3 V
- Costs little, so it can stay inside a finished project
Raspberry Pi Pico key facts
| Microcontroller | RP2040, two ARM Cortex-M0+ cores, up to 133 MHz |
|---|---|
| Memory | 264 KB RAM, 2 MB flash |
| GPIO | 26 pins (GP0 to GP22 and GP26 to GP28) at 3.3 V |
| Analog inputs | 3 (GP26, GP27, GP28), 12-bit; read_u16() gives 0 to 65535 |
| PWM | on every GPIO pin (16 channels) |
| On-board LED | GP25 |
| Pin current | about 12 mA from one pin, 50 mA in total |
| Power | 5 V from USB (VBUS) or 1.8 to 5.5 V on VSYS; 3.3 V out on the 3V3 pin |
| Size | 51 mm × 21 mm, 40 pins 0.1 inch apart |
- What the Raspberry Pi Pico is
- What the Raspberry Pi Pico is for
- How the Raspberry Pi Pico runs your program and its pins
- How to use the Raspberry Pi Pico in the simulator
- Worked example
- Common mistakes
- Key words
- What to learn first and next
What the Raspberry Pi Pico is
The Raspberry Pi Pico is a microcontroller board: a small, low-cost circuit board built around one chip that is a complete tiny computer. The chip is the RP2040, designed by Raspberry Pi. It has two processor cores that run at up to 133 MHz, 264 KB of RAM, and 2 MB of flash memory on the board to hold the program. The board is 51 mm long and 21 mm wide, with a micro USB socket at one end, a small button marked BOOTSEL and a green LED.
A microcontroller board is not the same thing as a Raspberry Pi computer such as the Raspberry Pi 4 or 5. Those run an operating system, need a microSD card and take some seconds to start. A Pico has no operating system. It holds one program in its flash memory and starts running it the moment power is connected. That makes it the better choice for a project that must simply switch on and work: a sensor, a light, a small robot.
The Pico came out in 2021 and was the first product to use a chip designed by Raspberry Pi. It is usually programmed in MicroPython, a small version of Python for microcontrollers, and it can also run Arduino C++ code. In the simulator you can use either: a program that has void setup() is run as C++, and anything else as MicroPython.
What the Raspberry Pi Pico is for
- A first microcontroller. MicroPython is quick to learn, and a program runs as soon as it is saved to the board.
- Reading sensors. Three analog inputs read potentiometers, light sensors and temperature sensors directly.
- Controlling outputs. LEDs, buzzers, servos and, through a driver, motors.
- Projects that stay built. The board is cheap and uses little power, so it can be left inside a finished project.
- Not the best choice when the project needs a screen, files, a camera or the internet. Use a Raspberry Pi computer, or a Pico W for Wi-Fi.
How the Raspberry Pi Pico runs your program and its pins
One program, straight away. You write the program on a computer and copy it to the board over USB. It is kept in flash memory, so it is still there after the power has been off. When power comes back, the program starts from its first line and usually runs in a while True: loop for ever.
The pins. The board has 40 pins, 20 along each long edge. 26 of them are GPIO pins, named GP0 to GP22 and GP26 to GP28. The rest are power and ground: VBUS is the 5 V from USB, VSYS is the power input, 3V3 gives 3.3 V out, and eight pins are GND. A GPIO pin that is HIGH gives 3.3 V. The pins are not 5 V tolerant.
Digital pins in MicroPython. The machine module gives you the pins. led = Pin(15, Pin.OUT) makes GP15 an output; led.on(), led.off() and led.toggle() switch it. button = Pin(14, Pin.IN, Pin.PULL_UP) makes an input with the pull-up resistor inside the chip switched on, and button.value() reads it: 0 while a button to GND is pressed.
Analog inputs. Unlike a Raspberry Pi computer, the Raspberry Pi Pico can measure a voltage. GP26, GP27 and GP28 go to an analog-to-digital converter with 12 bits, so it can tell 4,096 levels apart between 0 V and 3.3 V. In MicroPython ADC(26).read_u16() stretches the result to a number from 0 to 65535, so the same code works on boards with other converters.
PWM. A digital pin is only on or off. To dim an LED or set a servo, the board switches the pin on and off very fast and changes the fraction of time it is on. pwm = PWM(Pin(15)), pwm.freq(1000) and pwm.duty_u16(32768) give half brightness, because 32768 is half of 65535.
The LED and the BOOTSEL button. The green LED on the board is on GP25; Pin("LED", Pin.OUT) also finds it and works on every Pico. To load new firmware on a real board, hold BOOTSEL while plugging in the USB cable: the Pico then appears on the computer as a USB drive.
How to use the Raspberry Pi Pico in the simulator
- Open the Free build and choose Raspberry Pi Pico (MicroPython) under Board, or open the Studio and add the board from Components › Boards.
- Read the starter program in the Code panel. It blinks the LED on the board with
Pin("LED", Pin.OUT). - Press Run. The LED next to the USB socket blinks and the terminal panel shows what the program prints.
- Add an LED and a 220 Ω resistor between GP15 and a GND pin, and change the program to use
Pin(15, Pin.OUT). - Add a potentiometer with its middle leg on GP26 and its outer legs on 3V3 and GND, and print
ADC(26).read_u16()while you turn it. - Then open a guided project below, such as “Blink an LED in MicroPython”, and press Check when your program works.
Worked example
Question. A potentiometer on GP26 of a Raspberry Pi Pico is turned so that its middle leg is at 1.1 V. What number does ADC(26).read_u16() give, and what does that number do when it is passed to duty_u16()?
- The analog input measures from 0 V to 3.3 V.
- The fraction of full scale is 1.1 V ÷ 3.3 V = 0.333, one third.
- read_u16() gives a number from 0 to 65535, so it gives about 0.333 × 65535 = 21,845.
- duty_u16() uses the same 0 to 65535 scale, so 21,845 means the pin is on for one third of the time.
- An LED on that pin shines at about one third of full brightness.
Answer. read_u16() gives about 21,845. Passed to duty_u16(), it sets the PWM signal to about 33 %, so the brightness follows the knob with no extra arithmetic.
Common mistakes
- Using RPi.GPIO or gpiozero.Those are libraries for the Raspberry Pi computers. A Pico runs MicroPython: write from machine import Pin.
- Connecting 5 V to a GPIO or analog pin.The pins are 3.3 V only. Power a potentiometer from the 3V3 pin, not from VBUS, so its output never goes above 3.3 V.
- Expecting analogRead values from 0 to 1023.read_u16() gives 0 to 65535. Divide by 65535 to get a fraction, or multiply the fraction by 3.3 to get volts.
- Using an analog sensor on a pin that is not GP26, GP27 or GP28.Only those three pins can measure a voltage.
- Wiring an LED with no resistor.Put a resistor of about 220 Ω in series so the pin gives only a few milliamps.
- Writing time.sleep(500) for half a second.Python counts in seconds: time.sleep(0.5). For milliseconds MicroPython also has time.sleep_ms(500).
- Using Pin(25) for the LED on a Pico W.It only works on the Pico and Pico 2. Pin("LED", Pin.OUT) works on all of them.
Key words
- Microcontroller
- A small, complete computer on one chip, with a processor, memory and input and output pins.
- Pin (of a microcontroller)
- A metal contact on a chip or board through which it reads an input or drives an output.
- MicroPython
- A small version of the Python language made to run on microcontrollers.
- Flash memory
- Memory that keeps what is stored in it when the power is off.
- GPIO
- General-purpose input and output: a pin that a program can set HIGH or LOW, or read.
- Analog-to-digital converter
- A circuit that measures a voltage and gives it as a whole number (ADC).
- Resolution (of a converter)
- The number of steps a converter can tell apart. Ten bits give 1,024 steps; twelve bits give 4,096.
- Pulse-width modulation
- Switching a pin on and off quickly so that the fraction of time it is on sets the average power (PWM).
- Pull-up resistor
- A resistor that joins an input pin to the supply voltage, so the pin reads HIGH when nothing else drives it.
- LED
- A light-emitting diode: a component that gives out light when current flows through it in one direction.
- Resistor
- A component made to have a fixed resistance.
- Ground
- The point in a circuit taken as zero volts, from which other voltages are measured.
See every key word in the glossary
What to learn first and next
- Ohm’s law calculator: Voltage, current and resistance.
- LED resistor calculator: Work out the resistor that an LED needs on a 3.3 V pin.
- Voltage divider calculator: A potentiometer is a voltage divider you can turn.
- Blink an LED in MicroPython: The first guided project for this board.
- Dim an LED with a knob in MicroPython: Analog input and PWM together.
- Raspberry Pi Pico W: The same board with Wi-Fi.
- Raspberry Pi Pico 2: The faster board that followed.
- Raspberry Pi course: Every Raspberry Pi lesson in teaching order.
How it works
The RP2040 chip has two ARM Cortex-M0+ cores running at up to 133 MHz, with the program kept in a separate 2 MB flash memory chip. Unlike the Raspberry Pi 4, the Pico has no operating system: it is a microcontroller, like an Arduino. It has 26 GPIO pins at 3.3 V, named GP0 to GP28. Three of them (GP26, GP27 and GP28) are analog inputs with a 12-bit converter, and every GPIO pin can make PWM. In MicroPython a pin is an object: led = Pin(15, Pin.OUT), then led.on(). Analog readings come from ADC(26).read_u16() as a number from 0 to 65535. In this simulator the Pico runs MicroPython, and if you paste an Arduino sketch with void setup() it runs that as C++ instead.
What it is made of
- Microcontroller: RP2040 silicon chip in a black plastic package SiCu
- Circuit board: Glass-fibre and epoxy with copper tracks and gold-plated edge pads CuAuSiO
- USB socket and crystal: Steel shell; a quartz crystal that keeps time at 12 MHz FeSiO
- Solder: Lead-free tin alloy SnAgCu
Where the materials come from: Silicon from quartz sand; copper from ores in Chile and Peru; gold for the edge pads from many mining countries; tin from Indonesia and China. The boards are assembled in Wales.
The chemistry
The gold plating on the edge pads is only a few millionths of a millimetre thick. Gold does not react with oxygen, so the pads stay clean and easy to solder for years.
Biology connection
A microcontroller reads inputs, decides and acts in a loop, many times a second. A reflex does the same job in your body: a sensor, a short path through the spinal cord, and a muscle. Reflex arc →
Safety and the environment
The pins are 3.3 V only: never connect 5 V to a GP pin. One pin gives about 12 mA at most, and all pins together about 50 mA, so use a transistor for motors. Recycle as e-waste.
Did you know? The RP2040 name is a code: RP for Raspberry Pi, 2 for two cores, 0 for the Cortex-M0+ type, and 4 and 0 for the amounts of memory.
Raspberry Pi Pico WRaspberry Pi Pico 2Raspberry Pi 4 Model BRaspberry Pi 5Arduino Uno R3Microcontroller simulator Elements inside: SiCuAuOFeSnAg
Try it in the simulator
Build and code a circuit with a Raspberry Pi Pico in these practice projects:
Questions students ask
What does a Raspberry Pi Pico do?
A small, low-cost microcontroller board built around the RP2040 chip. It runs one program, in MicroPython or Arduino C++, as soon as it has power. Main functions: runs one MicroPython or Arduino program as soon as it has power; reads three analog inputs and makes PWM on any pin; controls LEDs, sensors and small motors at 3.3 V; costs little, so it can stay inside a finished project.
What is the difference between a Raspberry Pi Pico and a Raspberry Pi 4?
A Raspberry Pi Pico is a microcontroller board: it runs one program directly on its RP2040 chip, has analog inputs, and starts the moment it gets power. A Raspberry Pi 4 is a full computer with an operating system, a screen output and far more memory, but no analog inputs. Use a Pico to control a circuit, and a Pi 4 when the project also needs a desktop, a camera or a lot of computing.
How does a Raspberry Pi Pico work?
The RP2040 chip has two ARM Cortex-M0+ cores running at up to 133 MHz, with the program kept in a separate 2 MB flash memory chip. Unlike the Raspberry Pi 4, the Pico has no operating system: it is a microcontroller, like an Arduino. It has 26 GPIO pins at 3.3 V, named GP0 to GP28. Three of them (GP26, GP27 and GP28) are analog inputs with a 12-bit converter, and every GPIO pin can make PWM. In MicroPython a pin is an object: led = Pin(15, Pin.OUT), then led.on(). Analog readings come from ADC(26).read_u16() as a number from 0 to 65535. In this simulator the Pico runs MicroPython, and if you paste an Arduino sketch with void setup() it runs that as C++ instead.
What is a Raspberry Pi Pico made of?
Microcontroller: RP2040 silicon chip in a black plastic package. Circuit board: Glass-fibre and epoxy with copper tracks and gold-plated edge pads. USB socket and crystal: Steel shell; a quartz crystal that keeps time at 12 MHz. Solder: Lead-free tin alloy.
Is a Raspberry Pi Pico safe? How should it be recycled?
The pins are 3.3 V only: never connect 5 V to a GP pin. One pin gives about 12 mA at most, and all pins together about 50 mA, so use a transistor for motors. Recycle as e-waste.
More boards and wiring
Connected tools
The same idea from another angle, across the site.