HT16K33

This MicroPython and CircuitPython library provides a hardware driver for a variety of displays based on the Holtek KT16K33 controller chip, including four-digit, seven-segment LEDs; four-digit, 14-segment LEDs; 8x8 and 16x8 monochrome matrix LEDs; and bi-colour 8x8 matrix LEDs. It also supports four-digit, 14-segment LEDs based on the VK16K33 controller from Freenove.

It now includes a ‘generic’ driver for HT16K33s connected directly to 1-8 digits, in any combination of single- and multiple-digit units. The limit is set by the available HT16K33 pins (the eight COM pins).

Import the Drivers

The driver package comprises a parent generic HT16K33 class and child classes for the various displays themselves. All your code needs to do is import the latter. For example:

from ht16k33 import HT16K33Segment

You can then instantiate the driver object. This requires a configured I²C bus object as generated by your chosen version of Python.

Some methods are provided by the parent module, others by the display module. All available methods are documented under a given display module’s documentation.

You will need to add both the child display driver module and the parent ht16k33.py file to your device.

Install the Drivers

MicroPython MIP Install

You can install the drivers using MicroPython’s MIP module. This requires a board running MicroPython 1.2.0 or above and connected to the Internet. Add the following to your code:

import mip
mip.install('github:smittytone/HT16K33-Python')

If your board is not Internet-capable, you can install locally using the mpremote tool:

mpremote mip install github:smittytone/HT16K33-Python

Alternatively, use our convenient installer script:

./tools/mpinstall.sh

To install pre-compiled versions of the library files, run:

./tools/mpinstall.sh mpy

This requires MicroPython’s mpy-cross tool installed on your computer.

CircuitPython Install

Drag and drop the ht16k33 folder to the mounted board’s lib folder. To save space, remove any driver files you don’t need.

Reducing Memory Usage

Adding the driver code may prove too much for certain CircuitPython devices which have limited amounts of memory. To overcome this, use MicroPython’s mpy-cross compiler. This will compile the raw Python into a highly compact form as a .mpy file. Copy ht16k33.mpy and the device-specific .mpy file to your device in place of the .py versions.

For MicroPython boards, I recommend you use the mpinstall.sh script to compile and install .mpy versions if the library files all in one go.

Compatibility

HT16K33 is compatible with MicroPython and CircuitPython.

Source Code

You can find the source code on GitHub.

Display-specific Modules