How to Set Up and Program Raspberry Pi Pico

The Raspberry Pi Pico is an intriguing board. Rather than be some other Linux unmarried board laptop like each different Raspberry Pi, the Pico is a cheap Arm primarily based microcontroller which we will be able to program the usage of C/C++ and MicroPython. In this educational we will be able to introduce how to get began with the Raspberry Pi Pico, If you want to to know extra technical information about the board, then check out our assessment 

How to Set Up the Raspberry Pi Pico 

1. Download the MicroPython UF2 document from the MicroPython tab. 


(Image credit score: Tom’s Hardware)

2. Push and dangle the BOOTSEL button at the Pico, then attach to your laptop the usage of a micro USB cable. Release BOOTSEL as soon as the force RPI-RP2 seems to your laptop.

Raspberry Pi Pico Bootsel Button

(Image credit score: Future)

3.  Drag and drop the UF2 document on to the RPI-RP2 force. The Raspberry Pi Pico will reboot and will now run MicroPython. 

Pico Python is MicroPython for the Raspberry Pi Pico. If you will have by no means used MicroPython, this is a model of Python 3 advanced for microcontrollers. If you’ll write Python, then you’ll write MicroPython. To write MicroPython code, we’d like to use a devoted editor and the default, elementary editor is Thonny which is what we will use for this educational.

1. Download and set up Thonny on your OS, for those who don’t have already got it. You can grasp it free of charge from the Thonny web site. In our case, it’s v 3.3.2 for Windows.

2. In a internet browser, download the specified  backend for Thonny to be in contact with the Raspberry Pi Pico.

3. In Thonny, move to Tools > Manage Packages and make a selection Install from native document. Navigate to the place the document has been downloaded and make a selection the document to set up. When executed restart Thonny


(Image credit score: Tom’s Hardware)

4.  Connect the Raspberry Pi Pico to your laptop and in Thonny move to Tools > Options and click on at the Interpreter tab. From the interpreter dropdown record make a selection MicroPython (Raspberry Pi Pico). The port dropdown menu will also be left to robotically stumble on the Pico. Click Ok to shut. 


(Image credit score: Tom’s Hardware)

The Python Shell (often known as REPL, Read, Eval, Print, Loop) will now replace to display that the Pico is attached and running.

5. To check we will be able to write a handy guide a rough print serve as to say “Hello World.” Press Enter to run the code.

print(“Hello World”)


(Image credit score: Tom’s Hardware)

To additional check that we will be able to effectively program the Raspberry Pi Pico, we will write the “Hello World” an identical for {hardware} tasks, flashing an LED. This fast check guarantees that our {hardware} is operating, and it’ll introduce the MicroPython language and syntax in the most simple shape. 

Before we commence writing any code, we first want to cord up our check circuit. This would require header pins to be soldered to the Raspberry Pi Pico. To construct this undertaking you are going to want:

  • A part dimension breadboard
  • An LED
  • A 330 Ohm resistor

1. Insert the Raspberry Pi Pico into the breadboard in order that it sits over the central channel. Make certain that the Micro USB port is at one finish of the breadboard. 


(Image credit score: Tom’s Hardware)

2. Insert a 330 Ohm resistor into the breadboard, one leg will have to be inline with GND, which is pin 38. The different leg will have to be inserted into the – rail of the breadboard. This supplies us with a GND rail the place all pins in that rail are attached to GND. 


(Image credit score: Tom’s Hardware)

3.  Insert an LED, with the lengthy leg (the anode) inserted into the breadboard at pin 34, and the quick leg inserted into the GND rail. The circuit is now constructed. 


(Image credit score: Tom’s Hardware)

With the circuit constructed we will be able to now get started writing the code to flash (blink) the LED. 


(Image credit score: Tom’s Hardware)

4. Import the important libraries. Our code is written within the massive clean house above the REPL and we commence through uploading two MicroPython libraries. The first is the Pin elegance from the Machine library, the second one is utime, used to regulate the tempo of our code.

from device import Pin
import utime

5. Create an object, “led” which is used to create a hyperlink between the bodily GPIO pin and our code. In this situation, it’ll set GPIO 28 (which maps to bodily pin 34 at the board) as an output pin, the place present will go with the flow from the Raspberry Pi Pico GPIO to the LED. We then use the article to instruct the GPIO pin to pull low.n different phrases this may make sure that the GPIO pin is became off originally of our undertaking.

led = Pin(28, Pin.OUT)

6. Inside of some time True loop, a loop with out a finish, we toggle the LED on and off, and print a message to the Python Shell (REPL) to end up that the loop is operating. Lastly, we upload a nap to pause the code for one 2d between each and every iteration of the loop.

whilst True: led.toggle() print("Toggle") utime.sleep(1)

7. Click on Save and select to save the code to the MicroPython tool (Raspberry Pi Pico). Name the document and click on Ok to save. Your code will have to seem like this.

from device import Pin
import utime
led = Pin(28, Pin.OUT)
whilst True: led.toggle() print("Toggle")

8. To run the code, click on at the Green play / arrow button and the Python Shell will replace to say TOGGLE each 2d, and the LED will flash on and off.

Getting Started with Raspberry Pi Pico

(Image credit score: Tom’s Hardware)

We have effectively examined our Raspberry Pi Pico and we will be able to now transfer on to some other  undertaking. Such as finding out how to use sensors with the Raspberry Pi Pico.