Skip to main content

A lightweight CircuitPython library for controlling single-digit 7-segment displays

Project description

circuitpython-sevenseg

A lightweight CircuitPython library for controlling single digit 7 segment displays (common cathode or common anode).

Supports digits, uppercase & lowercase letters, and symbols works on Raspberry Pi Pico, Adafruit Feather, Seeed XIAO ESP32-S3, and any CircuitPython-supported board.

CircuitPython port of micropython-sevenseg


Installation

Copy the circuitpython_sevenseg/ folder to the lib/ directory on your CIRCUITPY drive:

CIRCUITPY/
└── lib/
    └── circuitpython_sevenseg/
        ├── __init__.py
        └── sevenseg.py

Pin Diagram

 ---a---
|       |
f       b
|       |
 ---g---
|       |
e       c
|       |
 ---d---   ● dp

Pin order: [a, b, c, d, e, f, g, dp]

Quick Start

import board
import time
from circuitpython_sevenseg import SevenSeg

seg = SevenSeg(
    pins=[board.GP2, board.GP3, board.GP4, board.GP5,
          board.GP6, board.GP7, board.GP8, board.GP9],
    common_anode=False
)

# Show a digit
seg.show(5)

# Show a letter
seg.show('A')

# Show with decimal point
seg.show(3, dp=True)

# Turn on decimal point only
seg.dot(True)

# Clear display
seg.clear()

# Release pins
seg.deinit()

API Reference

SevenSeg(pins, common_anode=False)

Initializes the display.

Parameter Type Description
pins list 8 pin objects in order [a, b, c, d, e, f, g, dp]
common_anode bool True for common anode, False for common cathode (default)

show(char, dp=False)

Displays a character on the 7-segment display.

Parameter Type Description
char int or str Digit 0–9 or supported character (see table below)
dp bool Also turn on decimal point (default False)

Raises ValueError if character is not supported.


clear()

Turns off all segments including the decimal point.


dot(on=True)

Toggles the decimal point without affecting other segments.

Parameter Type Description
on bool True = on, False = off (default True)

deinit()

Releases all GPIO pins. Call when done to free resources.


Supported Characters

Digits

0 1 2 3 4 5 6 7 8 9

Uppercase Letters

A B C D E F G H I J L N O P Q R S T U Y Z

K, M, V, W, X not supported — physically impossible on 7-segment display.

Lowercase Letters

a b c d e f g h i j l n o p q r s t u y

Symbols

- _ . ! ? ' " [ ] = + ^ (space)


Wiring Example — Raspberry Pi Pico / Pico 2W

Segment Pico Pin
a GP2
b GP3
c GP4
d GP5
e GP6
f GP7
g GP8
dp GP9

Examples

File Description
sevenseg_simpletest.py Basic 0–9 counter
sevenseg_all_chars.py All supported characters

License

MIT License © 2026 Kritish Mohapatra


Author

Kritish Mohapatra

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

circuitpython_sevenseg-1.0.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

circuitpython_sevenseg-1.0.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file circuitpython_sevenseg-1.0.1.tar.gz.

File metadata

  • Download URL: circuitpython_sevenseg-1.0.1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for circuitpython_sevenseg-1.0.1.tar.gz
Algorithm Hash digest
SHA256 45c88c2645379ab63e03826d74b152dda905fbce4ecaceb4b35ad9b0b77d4430
MD5 aacadc8d5d74e2b26cc0a5d1b8f72f16
BLAKE2b-256 b50a0936f798a7a0d786bbaa0afddce6ef9a3a60c1522937f3a539b1e9321a24

See more details on using hashes here.

File details

Details for the file circuitpython_sevenseg-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for circuitpython_sevenseg-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 36011dfa679f1ec77fab52c86e8bf7d91738a0b51a37966f33924ca88a640ec2
MD5 e5778156c65c9aa4ef4d20964fafbed5
BLAKE2b-256 60f7e5cff4bd2c3f9550e32e501691a3696fff08a7bd4cf85f5ff4302b0b3072

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page