Skip to main content

pymcu-sevenseg

pymcu-sevenseg banner

A PyMCU library for controlling a single-digit 7-segment display on bare-metal AVR (Arduino Uno / ATmega328P) firmware no interpreter, no runtime, compiled straight to machine code.

Supports Common Anode and Common Cathode displays, digits 0–9, most A–Z / a–z letters that are renderable on a 7-segment display, common symbols, and an optional decimal point (DP).

  • Author: Kritish Mohapatra
  • License: MIT
  • Year: 2026

Ported from the original micropython-sevenseg library to PyMCU's statically-typed Python subset. Validated on real Arduino Uno hardware via pymcu build and pymcu flash.


Installation

pip install --pre pymcu-sevenseg

Wiring

Connect each segment pin (a–g) through a current-limiting resistor (220–330Ω) to a digital pin on the Arduino Uno. Connect the display's common pin(s) to GND (common cathode) or 5V (common anode).

Segment Example Pin (Uno)
a Pin 2
b Pin 3
c Pin 4
d Pin 5
e Pin 6
f Pin 7
g Pin 8
dp Pin 9 (optional)

Usage

from machine import Pin
from utime import sleep_ms
from sevenseg import SevenSeg

def main():
    # Common Cathode configuration with DP on Pin 9
    display = SevenSeg(2, 3, 4, 5, 6, 7, 8, pin_dp=9, has_dp=True, common_anode=False)

    count: uint8 = 0
    while True:
        display.show(count)
        sleep_ms(1000)
        count = count + 1
        if count > 9:
            count = 0

API Reference

SevenSeg(pin_a, pin_b, pin_c, pin_d, pin_e, pin_f, pin_g, pin_dp=0, has_dp=False, common_anode=False)

Creates a display driver instance. All pin arguments must be compile-time constant integers (const[uint8]).

  • pin_a ... pin_g — Segment pin numbers.
  • pin_dp — Decimal point pin number. Ignored unless has_dp=True.
  • has_dp — Whether a decimal point pin is wired (True / False).
  • common_anodeTrue for Common Anode displays, False (default) for Common Cathode.

show(digit, dp=False)

Displays a character. Accepts either a plain numeric digit (0–9) or an ASCII code (uint8).

  • Digits: 0–9 (or ASCII 48–57).
  • Letters: Most renderable uppercase and lowercase characters (e.g. ord('A') / 65, ord('b') / 98). Note: characters like K, M, V, W, X cannot be rendered clearly on 7 segments and are skipped.
  • Symbols: - _ . ! ? ' " [ ] = + ^ and space.
  • dp — Turn the decimal point on for this character (active only when has_dp=True). Note: characters . and ! automatically enable the decimal point.

clear()

Turns off all segments and the decimal point immediately.

Notes & Constraints

  • Compile-Time Pin Constants: Pin numbers must be literals known at compile time — this is a PyMCU language constraint (compile-time pin resolution), not a driver limitation.
  • Zero-Heap Design: Does not allocate dynamic memory on the heap; compiles directly to efficient static AVR assembly instructions.
  • Backend Compatibility: Tested and verified with pymcu-compiler[avr] (beta as of 0.1.0a10).

Download files

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

Source Distribution

pymcu_sevenseg-0.1.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

pymcu_sevenseg-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file pymcu_sevenseg-0.1.0.tar.gz.

File metadata

  • Download URL: pymcu_sevenseg-0.1.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pymcu_sevenseg-0.1.0.tar.gz
Algorithm Hash digest
SHA256 342b695c2b419d9721b46a2c9155b1c28a2ffbcbb7413f74db35a1dab89d0f3a
MD5 8730bf01165494b5185a0ece6f10bef5
BLAKE2b-256 4651fff0950e7f03090f95ee7322ec56aad5a724adb3d773aeedc7bd4320397e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymcu_sevenseg-0.1.0.tar.gz:

Publisher: publish.yml on kritishmohapatra/pymcu-sevenseg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymcu_sevenseg-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pymcu_sevenseg-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pymcu_sevenseg-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 61d3096d173f1d6f9c3fe7ea67f76043f3ba553d61b1733a8e230676e3037f4c
MD5 5f42aed3109f1798183cea578afbfa35
BLAKE2b-256 da784c9c8cb49af36752a5a418f6dcc5b6835a4d06f2dae9d9b7e3bd6ded9191

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymcu_sevenseg-0.1.0-py3-none-any.whl:

Publisher: publish.yml on kritishmohapatra/pymcu-sevenseg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page