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.0.tar.gz (4.6 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.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: circuitpython_sevenseg-1.0.0.tar.gz
  • Upload date:
  • Size: 4.6 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.0.tar.gz
Algorithm Hash digest
SHA256 07c154db54d5a5df059fb62175843f0690a78dfd3cc6b16ad6c7a24843e9e0e7
MD5 cf0f7d3b5dd936e705ba497d9d5e50e2
BLAKE2b-256 441315c5e3397c8e8338a6920ccc05c70c98dfd9656a644497330f14564087d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for circuitpython_sevenseg-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d221f6e4930a2fcb224dd085cb40e45c8d40931ee288e50fb78772b9d660e0e9
MD5 0abf6127cba0041c1f90cbbfe71954c8
BLAKE2b-256 42cb92e094e81fa543678d943d78077cefb4b9cde9fce769fb47a8dd5a236b18

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