The RP2040 microcontroller at the heart of Pico is a brand new chip designed by Raspberry Pi. It’s high-performance, low-cost, and has a host of flexible interfacing options. We look at this in detail here.
This oscillator helps your microcontroller keep ticking along at the right speed.
Alongside the RP2040 chip, your Pico also includes 2MB of flash memory. If you’re used to the gigabytes of memory you get in modern computers, this may not sound like much, but microcontroller programs don’t tend to be very large. If you do need to store lots of data (such as if you’re logging sensor values), you could add additional storage such as an SD card.
The micro USB port on the front of Pico can be used to supply power and to send programs and data to the board. It also has more advanced functions. Your Pico can act as a USB device and interact with a computer in a similar way to any other USB device such as a keyboard or mouse. Want to build a custom game controller? Pico can do that. A little unusually, Pico can also act as a USB host. This means you can plug other USB devices into it. You can use a regular USB keyboard or mouse to get data in. In principle, any USB device should work, but bear in mind that your program will need to understand how to communicate with the device. There are some examples of both device and host USB at hsmag.cc/kVFRIG.
You can supply voltage either through the USB port or Vsys. If you attach a power supply (such as a battery) to Vsys via a Schottky diode, the system will take the larger of the two voltages. This allows you to have a backup power supply, or a separate power supply and not need to worry about problems when plugging Pico in for programming. Pico can take a wide range of input voltages: from 1.8 V to 5.5 V. You can power it from a single lithium-ion cell, three AA batteries, or any other power source in the range. There are more details on powering Pico, and example circuits, in the Pico data sheet at rptl.io/pico.
You can turn the 26 GPIO pins on and off, or read whether or not they have voltage applied to them from your code. They can turn LEDs on and off, read button presses, and control all manner of other hardware. If you need to interface with other digital devices, there are two each of I2C, SPI, and UART. There’s also a flexible I/O controller called PIO that makes it easy to connect to a wide range of devices.
GPIO pins 26, 27, and 28 can all read analogue values. They return a 12-bit number that shows the voltage (between 0 and 3.3 V). If you’d rather use a different maximum voltage (up to 3.3 V max), you can set it via the ADC_VREF pin.
The button on Pico is used to enter programming mode. Unplug Pico, hold down this button, then plug it in, and it’ll show up as a USB mass storage device that you can copy UF2 files to. You can get input from this button in your C/C++ programs – take a look at this example for details on how: hsmag.cc/xbYOhc.
GPIO 25 is connected to a green LED that you can program however you like. It can be an indicator that something’s happening on your project, or even a Morse code output.
Debugging microcontrollers can be tricky. When something’s not working, it’s not always easy to work out what’s not working, let alone why. Fortunately, Pico exposes three pins on the bottom edge, and these are for debugging using the Serial Wire Debug (SWD) protocol. If you’re using a Raspberry Pi as your main device to program Pico, you can connect these directly to the GPIO pins with no extra hardware other than a few wires. If you’re using a different computer, you’ll need an extra adapter. Pico can be used as a debug adapter for another Pico using the Picoprobe program. This interface allows you to add up to four breakpoints and two watchpoints. This gives you much more control about how your program runs as you develop software.
You can get your very own Pico by getting a paper copy of HackSpace mag issue 39 or subscribing to HackSpace magazine from just £10. If you're in the UK head here. For delivery elsewhere in the world, take a look here.