๐Ÿ”ข SevenSeg

January 25, 2026 ยท View on GitHub

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.

MicroPython ESP32 ESP8266 Pico 2 W License PyPI Awesome MicroPython


๐Ÿš€ Features

  • 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

โš™๏ธ Installation

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 โ†’ /

๐Ÿง  Pin Diagram (Typical)

 ---a---
|       |
f       b
|       |
 ---g---
|       |
e       c
|       |
 ---d---   โ— dp

๐Ÿงช Board Examples

BoardFileDescription
ESP32examples/esp32_basic_counter_example.pyDemo on ESP32 with GPIO 23โ€“17
ESP8266examples/esp8266_basic_counter_example.pyDemo on NodeMCU (D1โ€“D8 pins)
Raspberry Pi Pico 2 Wexamples/rpi_pico_2_w_counter_example.pyDemo using GP0โ€“GP7

๐Ÿงฉ Library API

FunctionDescription
show(num)Display a number (0โ€“9)
clear()Turn off all segments
dot(on=True)Turn the decimal point on/off
common_anodeSet True for common-anode displays

๐Ÿ“ฆ Folder Structure

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

๐Ÿ“œ License

This project is licensed under the MIT License.
ยฉ 2025 Kritish Mohapatra โ€“ Open Source for MicroPython Community ๐Ÿ’ก

๐Ÿ”„ What's New in v1.1.0

  • 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

โค๏ธ Contribute

Pull requests are welcome!
If you find a bug or want to suggest an improvement, feel free to open an issue.

๐ŸŒ Author

Kritish Mohapatra
๐Ÿ”— GitHub
๐Ÿ“ง kritishmohapatra06norisk@gmail.com

โœจ Made with passion for Embedded Systems and MicroPython learners.