﻿Hello,
This video is an introduction to Raspberry Pi Pico for experienced users of other Raspberry Pi
products such as Pi 4 or Pi Zero.
I will demonstrate how to set up the Pico micro-controller, connect it to your PC
and how to program it using MicroPython.
This device is an interesting addition to the Raspberry Pi ecosystem.
Unlike the previous products which are fully-functioning computers, Pico is a much simpler device, classified as a micro-controller.
It has the familiar 40-pin layout, similar to the standard Raspberry Pi,
offering a number of programmable GPIO ports and you can use a range
of programming languages to program it, with my preference being MicroPython.
Comparing the Pico to let’s say Pi 4, it’s like the proverbial apples to oranges,
but as far as attaching electronic components and writing programs for them there is significant overlap.
For now, the regular Raspberry Pi has an advantage.
I expect the gap will narrow, as new Pico generations come out and the software libraries mature.
Pico comes without breadboard headers attached, so if you plan to use it that way,
you will need to do a bit of soldering.
Soldering is a useful skill to have anyway, but if you need to learn it,
I suggest that you don’t make Pico your first soldering project. Practice a bit first!
I have attached the headers to another Pico board already.
This setup should be very familiar to you, if you use the cobbler connector with your regular Raspberry Pi.
Pico needs to be attached to a PC to set it up and to actually program it.
You will need a micro USB cable to make the connection.
Press and hold the BOOTSEL button while you connect your the Pico to your PC.
This will work in any environment, whether you use Windows,
MacOS or as it is in my case, Ubuntu Linux.
Your PC should recognize the Pico and present it to you as a USB storage device - just like a standard USB memory stick.
There are a couple of files on here already.
The index file will take you to a “Getting Started” page.
I will leave the reading to you and go straight into the programming.
Raspberry Pi Foundation recommends the Thonny environment to program the Pico using MicroPyton.
My Ubuntu Linux had it pre-installed,
but the Thonny website has a later version which I will be using.
Thonny is a generic IDE for Python programming and you need to set it up to talk to the Pico board.
There should be a selection button for that in the lower right corner.
You will be prompted to update the Pico with the latest MicroPython firmware,
and you can start programming as soon as this is done.
Let’s write a simple MicroPython program which will blink the onboard LED.
This should give you a feel what GPIO programming looks like on Pico.
The bulk of the GPIO-related code for the Pico can be currently found in the machine library.
You actually do not need to import this library entirely here,
as an LED can be controlled with just the Pin class.
Blinking of an LED requires a delay which is a standard Python sleep statement.
The onboard LED is attached to GPIO 25 which does not have a physical connection to the breadboard.
The Pin class represents a generic digital device and an LED happens to be of an OUTPUT type.
The blinking action is achieved by turning the LED on and off repeatedly,
which you probably knew already.
You have an option to save your finished program on your PC or on the Pico.
Normally programs in development should be saved on the PC and only saved on the Pico when you are finished.
Pico can essentially hold and run only one program at a time when detached from the PC.
Starting and stopping programs in Thonny is performed using menu options,
or keybaord options, whatever you prefer.
Of course, blinking the internal LED is just a test.
There is an entire world of possibilities ahead.
How about I will add 2 LEDs to the breadboard and blink them alternately...
The circuit is very simple, just don’t forget to disconnect the Pico while you build it.
Re-connect to the Pico but this time don't press the BOOTSEL button.
The updated code is very similar to the onboard LED.
I need to create 2 Pin objects referring to 2 physical GPIO ports and expand the while loop.
Here it is all done in action...
This project is essentially done and it’s ready to be transferred to the Pico for standalone use.
The program stored on the Pico needs a specific name – main.py. I could still run,
debug and change this program when saved that way, but now Pico can run this program
automatically on its own, without the PC, as soon as it’s powered next time.
Let me detach the board form my PC and demonstrate the process.
This time I will use a standard USB power bank.
If you want the stored program to be run automatically,
do not press and hold the BOOTSEL button when connecting power.
There it is!
This program will run as long the power is connected.
If you are not a subscriber yet, please subscribe as I add Raspberry Pi videos to my channel regularly.
Thanks for watching!