MicroPython

Note this page describes how to use a MicroPython.org version of this library with MicroPython boards. Skip back to the previous page if you're using a CircuitPython board like the Feather M0 express!

In addition to CircuitPython there's an older MicroPython version of the HT16K33 library that you can use with some MicroPython boards.  Before you get started it will help to be familiar with these guides for working with MicroPython:

See all the MicroPython guides in the learning system for more information.

MicroPython Module Install

To use the LED backpack with your MicroPython board you'll need to install the micropython-adafruit-ht16k33 MicroPython module on your board. Remember this module is for MicroPython.org firmware and not Adafruit CircuitPython!

First make sure you are running the latest version of MicroPython for your board.  If you're using the ESP8266 MicroPython port you must be running version 1.8.5 or higher as earlier versions do not support using .mpy modules as shown in this guide.  

Next download the latest ht16k33_matrix.mpy and ht16k33_seg.mpy files from the releases page of the micropython-adafruit-ht16k33 GitHub repository.  You'll need to copy all of the files to your MicroPython board's file system using a tool like ampy to copy the files to the board.

Usage

The following section will show how to control the LED backpack from the board's Python prompt / REPL.  You'll walk through how to control the LED display and learn how to use the MicroPython module built for the display.  As a reference be sure to see the micropython-adafruit-ht16k33 module documentation too.

First connect to the board's serial REPL so you are at the MicroPython >>> prompt.

MicroPython I2C Initialization

On MicroPython.org firmware which uses the machine API you can initialize I2C like the MicroPython I2C guide mentions.  For example on a board like the ESP8266 you can run (assuming you're using the default SDA gpio #4 and SCL gpio #5 pins like on a Feather & LED backpack FeatherWing):

Download: file
import machine
i2c = machine.I2C(scl=machine.Pin(5), sda=machine.Pin(4))

Matrix & Segment Display Usage

Once you've initialized the I2C bus you're ready to create instances of the matrix and display classes.  These classes are exactly the same as the CircuitPython version of the library, but instead live in the ht16k33_matrix module.  For example to create a 8x8 matrix you could run:

Download: file
import ht16k33_matrix
matrix = ht16k33_matrix.Matrix16x8(i2c)

See the CircuitPython library usage for information on the functions you can call to control the matrix and segment displays.  Once you've created the display class like above its usage is the same as with CircuitPython!

This guide was first published on Nov 02, 2016. It was last updated on Nov 02, 2016. This page (MicroPython) was last updated on Sep 18, 2019.