A lightweight, easy-to-use MicroPython library to control single-digit 7-segment displays (common cathode or common anode) on boards like ESP32, ESP8266, and Raspberry Pi Pico 2 W.
- Supports both Common Cathode & Common Anode types
- Optional decimal point (dp) control
- Simple API:
show(),clear(),dot() - Works on multiple MicroPython boards
- Clean, modular design for beginners & embedded developers
Copy the sevenseg.py file to your device using Thonny, ampy, or rshell.
Or clone this repo:
git clone https://github.com/kritishmohapatra/micropython-sevenseg.git
# Copy to the root directory of your MicroPython board
sevenseg.py → / ---a---
| |
f b
| |
---g---
| |
e c
| |
---d--- ● dp
| Board | File | Description |
|---|---|---|
| ESP32 | examples/esp32_basic_counter_example.py |
Demo on ESP32 with GPIO 23–17 |
| ESP8266 | examples/esp8266_basic_counter_example.py |
Demo on NodeMCU (D1–D8 pins) |
| Raspberry Pi Pico 2 W | examples/rpi_pico_2_w_counter_example.py |
Demo using GP0–GP7 |
| Function | Description |
|---|---|
show(num) |
Display a number (0–9) |
clear() |
Turn off all segments |
dot(on=True) |
Turn the decimal point on/off |
common_anode |
Set True for common-anode displays |
micropython-sevenseg/
├── sevenseg/
│ ├── __init__.py
│ └── sevenseg.py
├── examples/
│ ├── sevenseg_esp32_demo.py
│ ├── sevenseg_esp8266_demo.py
│ └── sevenseg_pico2w_demo.py
├── setup.py
├── LICENSE
└── README.md
This project is licensed under the MIT License.
© 2025 Kritish Mohapatra – Open Source for MicroPython Community 💡
- Optimized segment control logic using XOR operation
- Correct decimal point (DP) behavior for common anode and cathode displays
- Cleaner and faster pin value handling
- Community-reviewed improvements
Pull requests are welcome!
If you find a bug or want to suggest an improvement, feel free to open an issue.
Kritish Mohapatra
🔗 GitHub
📧 kritishmohapatra06norisk@gmail.com
✨ Made with passion for Embedded Systems and MicroPython learners.