In my continued mission to purchase every device that the Raspberry Pi Foundation releases, I acquired a Raspberry Pi Pico shortly before the holiday season 😀.
I splashed the cash and spent £11 on a Maker Pi Pico, which is a Pico that is pre-soldered onto a maker board that has an LED indicator for each GPIO pin, 3 programmable pushbuttons, an RGB LED, buzzer, stereo 3.5mm audio jack, micro-SD card slot, ESP-01 socket and 6 Grove ports.
To program the device using MicroPython you need to install MicroPython on the Pico (full instructions here) and then install the Thonny Python IDE on the device you’d like to do development on (Windows, Mac or Linux), I may add that if you wanted to do development on a Raspberry Pi and you are running Raspberry Pi OS, this step isn’t required as Thonny comes pre-installed. A step-by-step guide on how to use Thonny with a Pico is available here.
The biggest mistake I made was to use a cheap USB cable that didn’t support data, I was scratching my head for a while figuring out why my Windows 11 machine couldn’t see the Pico (it presents itself as a mass storage device) until I tried another cable, which worked like a charm.
After playing around with some of the sample Python scripts for the Maker Pi Pico, I thought I’d go all 1980s and try to re-create a super-basic graphic equalizer. If you don’t have a clue what I’m talking about check out this YouTube video for a demo – https://www.youtube.com/watch?v=GlgVoYH6bPo.
I put together the script below (also available on GitHub here). Which does the following:
- Turns off the LEDs attached to the GPIO pins 0-15
- Generates a random number between 0-15
- Lights up each LED in order e.g. if 4 is the random number generated it will turn on the LED for GPIO 0, 1, 2, 3 and then 4
- Turns off each LED in reverse order, therefore 4, 3, 2, 1 and then 0
- Repeats step 2
I’m sure that there are far more practical applications for a Pico, but this kept me amused for a short while.
import machine import utime import random for i in range(15): machine.Pin(i,machine.Pin.OUT) for i in range(15): machine.Pin(i).value(0) def lightup(id): for i in range(id): machine.Pin(i).value(1) utime.sleep(0.01) for i in reversed(range(id)): machine.Pin(i).value(0) utime.sleep(0.01) while True: randnum = random.randint(0,15) lightup(randnum) utime.sleep(0.15)
Here it is in all its glory: