Raspberry Pi Pico Project

How to use external LED with Raspberry Pi Pico


Welcome to our beginner’s guide on how to use an external LED with Raspberry Pi Pico! If you’re new to the world of Raspberry Pi and electronics, don’t worry – we’ll walk you through the process step by step. In this tutorial, you’ll learn the basics of setting up your Raspberry Pi Pico, understanding the GPIO (General Purpose Input/Output) pins, and how to connect and control an external LED. We’ll start with a brief introduction to the Raspberry Pi Pico, its capabilities, and why it’s a great tool for learning electronics and programming. Then, we’ll delve into the components you’ll need for this project, including the LED, resistors, and connecting wires. Next, we’ll guide you through the physical setup – showing you how to correctly connect the LED to the Raspberry Pi Pico without causing any damage. Following that, we’ll dive into the programming aspect. You’ll learn how to write a simple script in MicroPython to control the LED – turning it on and off or even making it blink. By the end of this guide, you’ll have a solid understanding of basic electronics and programming, empowering you to embark on more complex Raspberry Pi Pico projects in the future. Let’s get started and light up your learning journey with Raspberry Pi Pico and LEDs!

Amazon Links:

Raspberry Pi Pico




Jumper Wires

Micro-USB Cable

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

What is Raspberry Pi Pico?

external led with Raspberry pi pico

Raspberry Pi Pico is a microcontroller board that offers a low-cost and versatile option for learning and experimenting with electronics. It’s powered by a custom-designed RP2040 microcontroller chip, a significant leap forward in microcontroller technology, and can be programmed using MicroPython or C/C++. The RP2040 chip features a dual-core ARM Cortex-M0+ processor, which provides ample computational power for a wide range of applications, from simple LED control to more complex robotics projects.

One of the key advantages of the Raspberry Pi Pico is its ease of use for beginners, while still offering advanced features for more experienced users. The board is equipped with a variety of GPIO pins, including digital and analog inputs and outputs, allowing it to interface with a wide array of sensors, motors, and other electronic components.

In terms of programming, the Raspberry Pi Pico is highly accessible. MicroPython, a simplified version of the popular Python programming language, is particularly well-suited for beginners. It enables users to get started quickly with clear, readable code. For those with more experience, the Pico also supports C and C++, providing a pathway to more advanced and efficient programming techniques.

The board also features onboard memory, including 264KB of SRAM and 2MB of onboard flash memory, which is more than sufficient for most beginner and intermediate projects. Additionally, the Pico is designed with energy efficiency in mind, making it suitable for battery-powered and portable applications.

Moreover, the Raspberry Pi Pico’s design includes support for a range of peripherals and interfaces, such as SPI, I2C, and UART, expanding its capabilities in terms of communication with other devices and sensors. This makes it an excellent choice for a wide range of projects, from home automation systems to educational tools for schools.

Getting Started

Before we dive into using an external LED with Raspberry Pi Pico, let’s make sure you have everything you need. Ensuring that you have all the necessary components at hand is crucial for a smooth and successful project. Here’s a comprehensive list of the items you’ll need:

Raspberry Pi Pico: This is the central component of our project. The Pico is a versatile microcontroller board powered by the RP2040 chip, suitable for various electronics projects.

External LED: LEDs (Light Emitting Diodes) are simple yet versatile components used in many electronics projects. They’re perfect for beginners due to their simplicity and clear visual feedback. You can choose any color you like.

Resistors: These are essential to prevent too much current from passing through your LED, which could potentially damage it. Typically, a 330-ohm resistor is a good choice for most LEDs, but this can vary depending on the LED’s specifications.

Breadboard: A breadboard is a tool for constructing a temporary prototype of an electronic circuit and for experimenting with circuit designs. This is where you’ll be setting up your connections between the Pico, the LED, and the resistor.

Jumper Wires: These wires will help you connect the Raspberry Pi Pico to the breadboard and then to the LED and resistors. You’ll need a few of them, preferably in different colors to help you keep track of your connections.

Micro-USB Cable: This is used to connect your Raspberry Pi Pico to your computer. It not only allows you to upload your code to the Pico but also provides it with power.

Computer with Programming Software: You’ll need a computer with the appropriate software to write and upload code to your Raspberry Pi Pico. You can use Thonny, a Python IDE, which is great for beginners and supports MicroPython.

With these components, you’re well-prepared to start your project. Each of these plays a crucial role in the setup and ensures that you can not only complete your project successfully but also understand the basics of electronics and programming as you go. Next, we’ll take you through the process of setting up your Raspberry Pi Pico and connecting your LED for your first exciting project.

Once you have all the necessary components, follow these steps:

Step 1: Connect the LED to Raspberry Pi Pico

external led with Raspberry pi pico

Start by connecting the LED to Raspberry Pi Pico using the breadboard and jumper wires. The LED has two legs: the longer leg is the positive (anode) leg, and the shorter leg is the negative (cathode) leg.

Connect the positive leg of the LED to resistor and the other end of the resistor to the GPIO pin 28 of Raspberry Pi Pico. Connect the negative leg of the LED to the GND (ground) pin on Raspberry Pi Pico.

Make sure the connections are secure and the LED is properly inserted into the breadboard.

Step 2: Write the Code

Now it’s time to write the code that will control the LED. Open your favorite code editor and create a new Python file.  In my case I am using Thonny IDE.

First, we need to import the necessary libraries:

Next, I define the variable for the pin that the LED is connected to:

Now, let’s write a simple program that turns the LED on and off:

This code uses a while loop to continuously turn the LED on for one second, then turn it off for one second, creating a blinking effect.

Step 3: Upload the Code to Raspberry Pi Pico

In my previous article, I explained in great detail how to set up the editor for uploading code to the Raspberry Pi Pico. Therefore, I highly recommend reading my previous article.

Step 4: Run the Code

Once the code is saved, simply click the ‘Run‘ button in the Thonny IDE, and the Raspberry Pi Pico will execute the program. You should then see the LED blinking on and off at one-second intervals.

external led with Raspberry pi pico

external led with Raspberry pi pico


Congratulations! You have successfully used an external LED with Raspberry Pi Pico.

We hope this guide has been a valuable resource in helping you get started with using an external LED with your Raspberry Pi Pico. Our aim was to provide clear and straightforward instructions, ensuring that even those new to electronics and programming could easily follow along and successfully complete the project. As you continue to explore and tinker with the Raspberry Pi Pico, you’ll find that it’s a versatile and powerful tool for all sorts of exciting projects, not just lighting up an LED.

Remember, this project is just the beginning! The Raspberry Pi Pico offers a vast playground for your creativity and learning. With its array of GPIO pins and the ability to work with a variety of sensors and components, the possibilities are nearly endless. You can create anything from simple automation systems to complex robotics projects. The skills you’ve learned here – setting up the hardware, wiring components, and writing simple code – are fundamental and will serve you well in more advanced projects.

Complete code:

Related Articles:

Creating LED Animations with Raspberry Pi Pico: A Step-by-Step Guide

Raspberry Pi Pico Install UF2 MicroPython Firmware and LED Blink Example

LED Control Using Push Button with Raspberry Pi Pico: Pressed and Released, Long Pressed


Related Articles

One Comment

  1. This article provides a clear and concise guide on integrating an external LED with the Raspberry Pi Pico, making it an excellent resource for beginners and hobbyists alike.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button