Micropython project on Rasperry Pi Pico - 2022 (2024)

Things used in this project

Hardware components

Micropython project on Rasperry Pi Pico - 2022 (1)
Arduino UNO
×1
  • Buy from Newark
  • Buy from store.arduino.cc
  • Buy from Adafruit
  • Buy from Arduino Store
  • Buy from CPC
Micropython project on Rasperry Pi Pico - 2022 (2)
Raspberry Pi Pico
×1
  • Buy from www.raspberrypi.org
  • Buy from CPC
Micropython project on Rasperry Pi Pico - 2022 (3)
DIYables Jumper Wires
×1
Micropython project on Rasperry Pi Pico - 2022 (4)
DIYables Breadboard
×1

Software apps and online services

Wokwi Arduino Simulator

Story

Introduction

Wokwi Arduino simulator is useful here for you to simulate your Micropython projects. In this project, you will simulate Raspberry Pi Pico on Micropython. You can run your Micropython code. You can use several peripherals such as temperature and humidity sensors, PIR sensors, light sensors, and more. In this project, you will connect a Pi Pico to a seven-segment display. To make this interesting, you will write code to toggle the counting up and down. You can display numbers from 0 to 9 and alphabets from A to F corresponding to hexadecimal values of 16 values. 0-F.

Components needed

  • Raspberry Pi Pico
  • Seven segment display
  • Slide switch
  • Wires

Project / Live simulation

https://wokwi.com/arduino/projects/300210834979684872

The code

 # My first MicroPython example of a 7-segment
# ascending/descending hexadecimal counter
# by Anderson Costa, created on 05.06.2021
from machine import Pin
from utime import sleep
# A
# ---
# F | G | B
# ---
# E | | C
# ---
# D
pins = [
Pin(2, Pin.OUT), # A
Pin(3, Pin.OUT), # B
Pin(4, Pin.OUT), # C
Pin(5, Pin.OUT), # D
Pin(6, Pin.OUT), # E
Pin(8, Pin.OUT), # F
Pin(7, Pin.OUT), # G
Pin(0, Pin.OUT) # DP (not connected)
]
# Common anode 7 segment
digits = [
[0, 0, 0, 0, 0, 0, 1, 1], # 0
[1, 0, 0, 1, 1, 1, 1, 1], # 1
[0, 0, 1, 0, 0, 1, 0, 1], # 2
[0, 0, 0, 0, 1, 1, 0, 1], # 3
[1, 0, 0, 1, 1, 0, 0, 1], # 4
[0, 1, 0, 0, 1, 0, 0, 1], # 5
[0, 1, 0, 0, 0, 0, 0, 1], # 6
[0, 0, 0, 1, 1, 1, 1, 1], # 7
[0, 0, 0, 0, 0, 0, 0, 1], # 8
[0, 0, 0, 1, 1, 0, 0, 1], # 9
[0, 0, 0, 1, 0, 0, 0, 1], # a
[1, 1, 0, 0, 0, 0, 0, 1], # b
[0, 1, 1, 0, 0, 0, 1, 1], # C
[1, 0, 0, 0, 0, 1, 0, 1], # d
[0, 1, 1, 0, 0, 0, 0, 1], # E
[0, 1, 1, 1, 0, 0, 0, 1], # F
]
def reset():
for pin in pins:
pin.value(1)
reset()
switch = Pin(11, Pin.IN)
while True:
if switch.value() == 1:
for i in range(len(digits)):
if switch.value() == 0:
break;
for j in range(len(pins) - 1):
pins[j].value(digits[i][j])
sleep(1)
else:
for i in range(len(digits) - 1, -1, -1):
if switch.value() == 1:
break;
for j in range(len(pins)):
pins[j].value(digits[i][j])
sleep(1)

The Connection Diagram

The simulation

Read more

Schematics

firefox_hpb8xepaev_AtgCnEQ5kX.png

Micropython project on Rasperry Pi Pico - 2022 (5)

Code

  • Untitled file

Untitled file

Python

# My first MicroPython example of a 7-segment# ascending/descending hexadecimal counter# by Anderson Costa, created on 05.06.2021from machine import Pinfrom utime import sleep# A# ---# F | G | B# ---# E | | C# ---# Dpins = [ Pin(2, Pin.OUT), # A Pin(3, Pin.OUT), # B Pin(4, Pin.OUT), # C Pin(5, Pin.OUT), # D Pin(6, Pin.OUT), # E Pin(8, Pin.OUT), # F Pin(7, Pin.OUT), # G Pin(0, Pin.OUT) # DP (not connected)]# Common anode 7 segmentdigits = [ [0, 0, 0, 0, 0, 0, 1, 1], # 0 [1, 0, 0, 1, 1, 1, 1, 1], # 1 [0, 0, 1, 0, 0, 1, 0, 1], # 2  [0, 0, 0, 0, 1, 1, 0, 1], # 3 [1, 0, 0, 1, 1, 0, 0, 1], # 4 [0, 1, 0, 0, 1, 0, 0, 1], # 5 [0, 1, 0, 0, 0, 0, 0, 1], # 6 [0, 0, 0, 1, 1, 1, 1, 1], # 7 [0, 0, 0, 0, 0, 0, 0, 1], # 8 [0, 0, 0, 1, 1, 0, 0, 1], # 9 [0, 0, 0, 1, 0, 0, 0, 1], # a [1, 1, 0, 0, 0, 0, 0, 1], # b [0, 1, 1, 0, 0, 0, 1, 1], # C [1, 0, 0, 0, 0, 1, 0, 1], # d [0, 1, 1, 0, 0, 0, 0, 1], # E [0, 1, 1, 1, 0, 0, 0, 1], # F ]def reset(): for pin in pins: pin.value(1)reset()switch = Pin(11, Pin.IN)while True: if switch.value() == 1: for i in range(len(digits)): if switch.value() == 0: break;  for j in range(len(pins) - 1): pins[j].value(digits[i][j]) sleep(1) else: for i in range(len(digits) - 1, -1, -1):  if switch.value() == 1: break;  for j in range(len(pins)): pins[j].value(digits[i][j]) sleep(1)

Credits

Hack star

75 projects • 101 followers

an Arduino enthusiast and an electronic hobbyist

Comments

Micropython project on Rasperry Pi Pico - 2022 (2024)

FAQs

Does Raspberry Pi Pico support MicroPython? ›

What is MicroPython? MicroPython is a full implementation of the Python 3 programming language that runs directly on embedded hardware like Raspberry Pi Pico. You get an interactive prompt (the REPL) to execute commands immediately via USB Serial, and a built-in filesystem.

What is better, MicroPython or CircuitPython? ›

For a user-friendly, beginner-oriented experience with strong hardware support, CircuitPython shines. On the other hand, if you seek a more mature ecosystem with efficient memory usage, MicroPython could be your go-to.

What is the best programming language for Raspberry Pi Pico? ›

A Raspberry Pi Pico responds to a variety of coding languages, including C, C++, and MicroPython. MicroPython is a more lightweight and simple version of traditional Python, and it is the most common language used by Raspberry Pi Pico hobbyists.

Is Raspberry Pi Pico faster than Arduino? ›

When it comes to processing power, the Raspberry Pi Pico boasts a dual-core ARM Cortex-M0+ processor running at 133 MHz, making it a formidable contender in the microcontroller arena. On the other hand, Arduino boards vary in terms of processing capabilities, with some featuring simpler architectures than others.

Can MicroPython run Python libraries? ›

Ability to run Python

MicroPython supports many standard Python libraries, supporting more than 80% of the features of Python's most used libraries. MicroPython was designed specifically to support the typical performance gap between microcontrollers and Python.

What microcontroller can run MicroPython? ›

The pyboard is the official MicroPython microcontroller board with full support for software features.

What are the downsides of MicroPython? ›

Disadvantages of MicroPython

MicroPython is interpreted rather than compiled, which can lead to slower execution speeds compared to compiled languages like C. For performance-critical applications, this can be a significant limitation.

How much RAM is needed for MicroPython? ›

MicroPython runs on a wide range of microcontrollers, as well as on Unix-like (including Linux, BSD, macOS, WSL) and Windows systems. Microcontroller targets can be as small as 256kiB flash + 16kiB RAM, although devices with at least 512kiB flash + 128kiB RAM allow a much more full-featured experience.

Is Arduino faster than MicroPython? ›

MicroPython is also a lot slower than Arduino style C++. Like, a LOT. So much slower that I am sort of amazed that MicroPython has any traction at all. An 80MHz microcontroller running C can go about as fast as a 800MHz microcontroller running MicroPython, if the benchmarks a friend showed me are accurate.

Is Raspberry Pi powerful enough for coding? ›

Assuming by "machine code level" you mean assembly language, then yes the Pi is great for that. The official OS called Raspbian comes with an excellent assembler already installed and ready to use. Also included is a C/C++ compiler called GCC.

Can Raspberry Pi Pico run machine learning? ›

It allows you to run machine learning models to do things like voice recognition, detect people in images, recognize gestures from an accelerometer, and other sensor analysis tasks. This version has scripts to upstream changes from the Google codebase.

Can Raspberry Pi Pico run 24 7? ›

Yes, it is completely normal to run a Pi 24/7. Even for years at a time. They use so little power that its not worth turning them off when not in use.

Is Raspberry Pi Pico good for image processing? ›

The RPi Pico uses an RP2040. RP2040 is a dual-core ARM Cortex-M0+. It comes with "264kB on-chip SRAM". You shouldn't expect this to have any power that's useful for image processing.

How powerful is Raspberry Pi Pico? ›

Designed by Raspberry Pi, RP2040 features a dual-core Arm Cortex-M0+ processor with 264kB internal RAM and support for up to 16MB of off-chip flash. A wide range of flexible I/O options includes I2C, SPI, and - uniquely - Programmable I/O (PIO).

How to load MicroPython on Raspberry Pi Pico? ›

Press and hold the BOOTSEL button and then connect the Pico to computer via a Micro USB cable. Release the BOOTSEL button after your Pico is mount as a Mass Storage Device called RPI-RP2. In the bottom right corner, click the interpreter selection button and select Install Micropython.

Can you use CircuitPython on Raspberry Pi Pico? ›

In MicroPython and CircuitPython you can create PIO control commands to script the peripheral and load it in at runtime. There are 2 PIO peripherals with 4 state machines each. There is great C/C++ support, Arduino support (guide), an official MicroPython port, and a CircuitPython port!

What IDE is used for Raspberry Pi Pico? ›

A Pi Pico can definitely be programmed from the arduino IDE (it can also be C/C++ programmed using a C toolchain involving make which is quite laborious to install (on Linux anyway) and which Rasp Pi explains in various tutorial pdfs).

How do I run a Python script on Raspberry Pi Pico? ›

Open and Run Script Directly
  1. Open Thonny IDE and plug the Pico into your computer with a micro USB cable and click on the “MicroPython (Raspberry Pi Pico). COMxx” interpreter in the bottom right corner.
  2. Open Script. For example, grayscale_2_get_value.py . ...
  3. Run the Script. ...
  4. Stop Running. ...
  5. Save or Save as.

References

Top Articles
'GMA' Deals & Steals on Tory's best birthday picks
'GMA' Deals & Steals takeover with gifts $20 and under
Spn 1816 Fmi 9
Combat level
Room Background For Zepeto
Can ETH reach 10k in 2024?
Flixtor The Meg
Black Gelato Strain Allbud
50 Meowbahh Fun Facts: Net Worth, Age, Birthday, Face Reveal, YouTube Earnings, Girlfriend, Doxxed, Discord, Fanart, TikTok, Instagram, Etc
World History Kazwire
Nebraska Furniture Tables
Der Megatrend Urbanisierung
Huntersville Town Billboards
18889183540
Quick Answer: When Is The Zellwood Corn Festival - BikeHike
Sef2 Lewis Structure
Hannah Palmer Listal
Unable to receive sms verification codes
§ 855 BGB - Besitzdiener - Gesetze
Geico Car Insurance Review 2024
Rgb Bird Flop
Craigs List Jax Fl
Best Laundry Mat Near Me
Sony Wf-1000Xm4 Controls
N.J. Hogenkamp Sons Funeral Home | Saint Henry, Ohio
Filmy Met
2430 Research Parkway
Sun-Tattler from Hollywood, Florida
404-459-1280
Ark Unlock All Skins Command
The Best Carry-On Suitcases 2024, Tested and Reviewed by Travel Editors | SmarterTravel
No Hard Feelings Showtimes Near Tilton Square Theatre
Srg Senior Living Yardi Elearning Login
Viewfinder Mangabuddy
Craigslist List Albuquerque: Your Ultimate Guide to Buying, Selling, and Finding Everything - First Republic Craigslist
Hebrew Bible: Torah, Prophets and Writings | My Jewish Learning
Überblick zum Barotrauma - Überblick zum Barotrauma - MSD Manual Profi-Ausgabe
Infinite Campus Farmingdale
11526 Lake Ave Cleveland Oh 44102
Jetblue 1919
Acts 16 Nkjv
Isabella Duan Ahn Stanford
Blue Beetle Showtimes Near Regal Evergreen Parkway & Rpx
UT Announces Physician Assistant Medicine Program
Candise Yang Acupuncture
Spurs Basketball Reference
Leland Westerlund
Free Carnival-themed Google Slides & PowerPoint templates
Ret Paladin Phase 2 Bis Wotlk
Nfhs Network On Direct Tv
Mazda 3 Depreciation
Noaa Duluth Mn
Latest Posts
Article information

Author: Carmelo Roob

Last Updated:

Views: 5715

Rating: 4.4 / 5 (45 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Carmelo Roob

Birthday: 1995-01-09

Address: Apt. 915 481 Sipes Cliff, New Gonzalobury, CO 80176

Phone: +6773780339780

Job: Sales Executive

Hobby: Gaming, Jogging, Rugby, Video gaming, Handball, Ice skating, Web surfing

Introduction: My name is Carmelo Roob, I am a modern, handsome, delightful, comfortable, attractive, vast, good person who loves writing and wants to share my knowledge and understanding with you.