Awesome
RP2040 Examples
Welcome to the RP2040 Examples repository! This collection showcases various projects and code samples for the Raspberry Pi Pico and other RP2040-based microcontroller boards. Whether you're a beginner looking to get started with MicroPython or an experienced developer exploring Golang on embedded systems, you'll find something useful here.
If you're also interested in Raspberry Pi projects using Golang, be sure to check out my Raspberry Pi Golang examples.
Table of Contents
Where to Buy
The Raspberry Pi Pico is a powerful yet affordable microcontroller that you can purchase from various retailers worldwide. Here are some trusted sources:
Documentation & Resources
To get the most out of your Raspberry Pi Pico, you can refer to the following documentation and resources:
- Official Raspberry Pi Pico Documentation - Comprehensive guide to getting started, programming, and using the Pico.
- Raspberry Pi Pico Pinout - Visual reference for the GPIO pins on the Pico.
MicroPython
MicroPython is an efficient and beginner-friendly way to program your Raspberry Pi Pico. Follow the links below to download the latest firmware:
MicroPython Examples
Explore these example scripts to get hands-on with MicroPython:
-
blink_with_pcf8574.py
Need more GPIO pins? Use a PCF8574 I/O expander. -
blink_with_ws2812.py
Create stunning LED displays with WS2812 light strips or modules. -
distance_with_hc-sr04.py
Accurately measure distances with the HC-SR04 ultrasonic sensor. -
info.py
Retrieve and display system information from your Raspberry Pi Pico. -
interactive_blink.py
Control GPIO pins interactively via text input, ideal for use with Thonny. -
morse_blink.py
Convert text into Morse code using an LED on the Pico. -
nunchuck.py
Interface with a Wii Nunchuck using a Nunchuck adapter. -
pwm_with_pca9685.py
Control up to 16 servos using the PCA9685 PWM driver. -
read_rfid_with_rc522.py
Implement RFID reading using the RC522 module. -
snake_on_hub75_zeroplayer.py
Display a snake animation on a Hub75 LED-Matrix with a Pimoroni Interstate 75 W. For a playable version, see my DIY-Arcade-Machine. -
weigh_with_hx711.py
Build a digital scale using a load cell and the HX711 A/D converter. -
wlan.py
Connect your Pico to WiFi and fetch data from the web. -
adc.py
Read analog signals using the Pico’s built-in ADC pins. -
balls_on_hub75.py
Simulate bouncing balls on a Hub75 LED-Matrix. -
conway_on_hub75.py
Implement Conway's Game of Life on a Hub75 LED-Matrix. -
floodfill_on_hub75.py
Visualize a flood fill algorithm on a Hub75 LED-Matrix. -
joystick.py
Interface a joystick with the Pico for simple gaming or control applications. -
read_rfid_with_rc522_with_light.py
Enhance RFID reading with visual feedback using LEDs.
Golang
For those who prefer to code in Golang, this section provides examples of using Golang on the Raspberry Pi Pico with the TinyGo compiler.
Golang Examples
-
blink.go
Blink an LED using Golang. Install TinyGo and compile with:tinygo build -o blink.uf2 -target=pico blink.go
Flash directly to the Pico with:
tinygo flash -target=pico blink.go
Add
-monitor
to the command to see the program’s output in the terminal. -
blink_with_ws2812.go
Control WS2812 LEDs using Golang, creating vibrant lighting effects. -
blink_with_ws2812_struct.go
An advanced example for controlling WS2812 LEDs using structured Golang code. -
read_rfid_with_rc522.go
Read RFID cards and tags using the RC522 module and Golang.
Contributing
Contributions are welcome! If you have a project or code sample you'd like to share, feel free to submit a pull request.
License
This repository is licensed under the MIT License. For more details, see the LICENSE file.
Feel free to explore the examples and contribute to this growing repository! Whether you're building a simple LED blinker or a complex sensor network, these examples are designed to help you get the most out of your Raspberry Pi Pico.