pymcu-sevenseg
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 unlesshas_dp=True.has_dp— Whether a decimal point pin is wired (True/False).common_anode—Truefor 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 whenhas_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 of0.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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
342b695c2b419d9721b46a2c9155b1c28a2ffbcbb7413f74db35a1dab89d0f3a
|
|
| MD5 |
8730bf01165494b5185a0ece6f10bef5
|
|
| BLAKE2b-256 |
4651fff0950e7f03090f95ee7322ec56aad5a724adb3d773aeedc7bd4320397e
|
Provenance
The following attestation bundles were made for pymcu_sevenseg-0.1.0.tar.gz:
Publisher:
publish.yml on kritishmohapatra/pymcu-sevenseg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymcu_sevenseg-0.1.0.tar.gz -
Subject digest:
342b695c2b419d9721b46a2c9155b1c28a2ffbcbb7413f74db35a1dab89d0f3a - Sigstore transparency entry: 2762685857
- Sigstore integration time:
-
Permalink:
kritishmohapatra/pymcu-sevenseg@d0f5940c13e79f48a52b62b146b55af700e6c4e0 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/kritishmohapatra
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d0f5940c13e79f48a52b62b146b55af700e6c4e0 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61d3096d173f1d6f9c3fe7ea67f76043f3ba553d61b1733a8e230676e3037f4c
|
|
| MD5 |
5f42aed3109f1798183cea578afbfa35
|
|
| BLAKE2b-256 |
da784c9c8cb49af36752a5a418f6dcc5b6835a4d06f2dae9d9b7e3bd6ded9191
|
Provenance
The following attestation bundles were made for pymcu_sevenseg-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on kritishmohapatra/pymcu-sevenseg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymcu_sevenseg-0.1.0-py3-none-any.whl -
Subject digest:
61d3096d173f1d6f9c3fe7ea67f76043f3ba553d61b1733a8e230676e3037f4c - Sigstore transparency entry: 2762686489
- Sigstore integration time:
-
Permalink:
kritishmohapatra/pymcu-sevenseg@d0f5940c13e79f48a52b62b146b55af700e6c4e0 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/kritishmohapatra
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d0f5940c13e79f48a52b62b146b55af700e6c4e0 -
Trigger Event:
release
-
Statement type: