If you read “How To Boot Raspberry Pi Pico for the First Time?” then you might have gotten an idea about the Raspberry Pi Pico. In that post, we covered most of the basic things required to know about the Raspberry Pi Pico. Please don’t skip reading that post if you are not aware of the Raspberry Pi Pico. Just to tell about the Raspberry Pi Pico, in short, it’s not a computer. It’s a small microcontroller board that is powerful enough to run programming languages like C and Python and allows you to do pretty much anything that you need to do for small electronic projects. Well, you can’t run the standard Python compiler on the Pico to control its hardware. You need to have MicorPython installed on it to program a Raspberry Pi Pico. We will show you how to install MicroPython on a Raspberry Pi Pico and how to program a Raspberry Pi Pico with MicroPython, in this post. Let’s get started.
MicroPython is a tiny open-source Python programming language interpreter that runs on small embedded development boards. MicroPython is designed to be as compatible with regular Python as possible (within reason) to allow you to transfer code with ease from desktop computers to microcontrollers and back.
MicroPython aims to be as practical as regular Python for everyday use on microcontrollers. MicroPython implements a subset of the Python 3 standard library and is extended to include modules for microcontroller-specific hardware. MicroPython runs bare-metal on microcontrollers and thus can be used to program them without an operating system. MicroPython is also packed with many features such as an integrated development environment (IDE), object relational mapper (ORM), and support for remote code repositories.
MicroPython is licensed under the MIT license, making it free and open-source software. MicroPython is currently developed by Damien George, with the latest releases available for download from MicroPython.org.
MicroPython is a great way to get started programming microcontrollers. By being able to program in MicroPython, you can develop code on your computer and then easily transfer it to a microcontroller to run. MicroPython is also very easy to use, thanks to its small size and feature-rich set of libraries. If you’re looking for a way to get started programming microcontrollers, MicroPython is a great option.
Micro-USB cable for connecting the Pico to a computer
Breadboard, jumper wires, LEDs etc. for building circuits (optional)
Software Prerequisites:
Thonny Python IDE installed on a Raspberry Pi or other Linux/Windows computer
MicroPython firmware installed on the Raspberry Pi Pico
Basic knowledge of Python programming
The post covers the process of installing MicroPython firmware on the Pico using the Thonny Python IDE. This involves booting the Pico into BOOTSEL mode, connecting it to Thonny, and initiating the firmware installation process.
Once MicroPython is installed, the Pico can be programmed using Python code. The post shows a simple example of turning an LED on and off using Python code to control a pin on the Pico.
So in summary, the key prerequisites are:
Raspberry Pi Pico hardware
Thonny IDE with MicroPython support
Understanding of basic Python syntax
Ability to connect the Pico to Thonny in BOOTSEL mode
Installing the MicroPython firmware on the Pico
With these elements covered, you will have what you need to start programming the Raspberry Pi Pico using MicroPython, as covered in the blog post. Let me know if you need any clarification or have additional questions!
You can program a Raspberry Pi Pico using C, Python, or any other programming language that supports Pico. However, we will show you how to program a Raspberry Pi Pico with MicoroPython, a subsidiary of Python. Before you program a Raspberry Pi Pico, it is a must to install it. Let’s see how to install MicroPython on a Raspberry Pi Pico.
There are multiple ways to install MicroPython on Raspberry Pi Pico. Let’s see how to install MicroPython on a Raspberry Pi Pico using Thonny Python IDE in this post.
1. Install MicroPython on Raspberry Pi Pico using Thonny Python IDE.2. Install MicroPython on Raspberry Pi Pico using
mode and flash the UF2 file.3. Building MicroPython From Source.
We are going to show you to boot the Raspberry Pi Pico in BOOTSEL mode by connecting to a Raspberry Pi. However, you can boot the Pico using any other Windows or Linux computer either if you don’t have Raspberry Pi with you. The reason to connect the Pico to the Pi is that Thonny Python IDE comes in Pi as part of the default packages. If you want to do this using Windows or Linux computer, then you should install Thonny Python IDE on your computer.
Connect your Raspberry Pi Pico to the Raspberry Pi through a micro USB cable by holding the BOOTSEL button (White color button near the micro USB connector) located on the Pico board.
Your Pico will be mounted as a mass storage drive on the Raspberry Pi as an RPI-RP2 drive.
Click on the Raspberry Pi icon then go to Programming and click on Thonny Python IDE
It is simple to connect your Pico to Thonny Python IDE. All you need to do is, click on the Python at the bottom right corner and select the MicorPython (Raspberry Pi Pico)
Immediately after you select the MicorPython (Raspberry Pi Pico), the installation wizard will pop up. Click on the Install button to begin the installation of MicruPython.
After the completion of the installation of MicroPython, Raspberry Pi Pico is ready to program.
We will show you how to use Pin number 25 to operate LED on the Raspberry Pi Pico board.
You just need to import Pin and create a variable method name ‘led’. And, call the high method to turn the LED on.
>>> from machine import Pin>>> led = Pin(25,Pin.OUT)>>> led.high()>>>
Call log method to turn the LED off
>>> from machine import Pin>>> led = Pin(25,Pin.OUT)>>> led.high()>>> led.low()>>>
Run this small script to blink the LED on your Pico board.
from machine import Pinimport utime
led = Pin(25,Pin.OUT)
delay = 0.25
while True:led.high()utime.sleep(delay)led.low()utime.sleep(delay)
We have shown you how to blink the LED as an example to program your Raspberry Pi Pico board to control hardware. You can program any PIN using Python like this.
We hope this post would help you learn how to install MicroPython on a Raspberry Pi Pico and how to program a Raspberry Pi Pico with MicroPython. Thanks for reading this tutorial post. Visit our social media page on Facebook, LinkedIn, Twitter, Telegram, Tumblr, Medium & Instagram, and subscribe to receive updates like this.
You may also like these articles:
Arun KL is a cybersecurity professional with 15+ years of experience in IT infrastructure, cloud security, vulnerability management, Penetration Testing, security operations, and incident response. He is adept at designing and implementing robust security solutions to safeguard systems and data. Arun holds multiple industry certifications including CCNA, CCNA Security, RHCE, CEH, and AWS Security.
“Knowledge Arsenal: Empowering Your Security Journey through Continuous Learning”
"Cybersecurity All-in-One For Dummies" offers a comprehensive guide to securing personal and business digital assets from cyber threats, with actionable insights from industry experts.
BurpGPT is a cutting-edge Burp Suite extension that harnesses the power of OpenAI's language models to revolutionize web application security testing. With customizable prompts and advanced AI capabilities, BurpGPT enables security professionals to uncover bespoke vulnerabilities, streamline assessments, and stay ahead of evolving threats.
PentestGPT, developed by Gelei Deng and team, revolutionizes penetration testing by harnessing AI power. Leveraging OpenAI's GPT-4, it automates and streamlines the process, making it efficient and accessible. With advanced features and interactive guidance, PentestGPT empowers testers to identify vulnerabilities effectively, representing a significant leap in cybersecurity.
Tenable BurpGPT is a powerful Burp Suite extension that leverages OpenAI's advanced language models to analyze HTTP traffic and identify potential security risks. By automating vulnerability detection and providing AI-generated insights, BurpGPT dramatically reduces manual testing efforts for security researchers, developers, and pentesters.
Microsoft Security Copilot is a revolutionary AI-powered security solution that empowers cybersecurity professionals to identify and address potential breaches effectively. By harnessing advanced technologies like OpenAI's GPT-4 and Microsoft's extensive threat intelligence, Security Copilot streamlines threat detection and response, enabling defenders to operate at machine speed and scale.