top of page
Writer's picturePrasannaa Kumar D

How to use Raspberry Pi Pico with CircuitPython?

Updated: Apr 7, 2021


Hey Guys! In this blog we'll see how to use a Pico with CircuitPython which is one of the easiest platform to code microcontrollers.


The Pico is a low-cost microcontroller board features a powerful new chip, theRP2040, and all the fixing's to get started with embedded electronics projects at a stress-free price. The Pico is 0.825" x 2" and can have headers soldered in for use in a breadboard or perfboard, or can be soldered directly onto a PCB with the castellated pads. There's 20 pads on each side, with groups of general purpose input-and-output (GPIO) pins interleaved with plenty of ground pins. All of the GPIO pins are 3.3V logic, and are not 5V-safe so stick to 3V! You get a total of25 GPIOpins (technically there are 26 but IO #15 has a special purpose and should not be used by projects), 3 of those can be analog inputs (the chip has 4 ADC but one is not broken out). There are no true analog output (DAC) pins.


What is CircuitPython?

CircuitPython is a programming language designed to simplify experimenting and learning to program on low-cost microcontroller boards. It makes getting started easier than ever with no upfront desktop downloads needed. Once you get your board set up, open any text editor, and get started editing code. It's that simple.


CircuitPython is based on Python!


Step 1:

Download and install the Mu editor. Download Mu from https://codewith.mu. Click the Download or Start Here links there for downloads and installation instructions. The website has a wealth of other information, including extensive tutorials and and how-to's.


Step 2:

Download the CircuitPython UF2 file from https://circuitpython.org/board/raspberry_pi_pico/ .


A file like this will be downloaded after you click the botton. (Don't forget to select english!).


Step 3:

Start with your Pico unplugged from USB. Hold down the BOOTSEL button, and while continuing to hold it (don't let go!), plug the Pico into USB. Continue to hold the BOOTSEL button until the RPI-RP2 drive appears!

If the drive does not appear, unplug your Pico and go through the above process again. A lot of people end up using charge-only USB cables and it is very frustrating! So make sure you have a USB cable you know is good for data sync.


Step 4:

Drag and drop the ufl file into the directory as shown above.


Step 5:

The first time you start Mu, you will be prompted to select your 'mode' - you can always change your mind later. For now please select CircuitPython! The current mode is displayed in the lower right corner of the window, next to the "gear" icon. If the mode says "Microbit" or something else, click the Mode button in the upper left, and then choose "CircuitPython" in the dialog box that appears. Mu attempts to auto-detect your board, so please plug in your CircuitPython device and make sure it shows up as a CIRCUITPY drive before starting Mu.


Code:


Simple LED :


import time

import board

import digitalio

led = digitalio.DigitalInOut(board.LED)

led.direction = digitalio.Direction.OUTPUT

while True:

led.value = not led.value

time.sleep(0.5)


LED Blink:


import time

import board

import digitalio

led = digitalio.DigitalInOut(board.LED)

led.direction = digitalio.Direction.OUTPUT

while True:

led.value = True

time.sleep(0.5)

led.value = False

time.sleep(0.5)



Hurray! We're done. Now start exploring Pico with CircuitPython.

Fee free to leave a message if you have any queries.


Happy Making!

59 views1 comment

Recent Posts

See All

1 bình luận


Haritha Hari
Haritha Hari
20 thg 3, 2021

Very well explained

Thích
bottom of page