It's easy to use 7-Segment Displays with Python and the Adafruit CircuitPython HT16K33 library.  This library allows you to easily write Python code to control the display.

We'll cover how to wire the 7-Segment Display to your Raspberry Pi. First assemble your 7-Segment Display.

Since there's dozens of Linux computers/boards you can use we will show wiring for Raspberry Pi. For other platforms, please visit the guide for CircuitPython on Linux to see whether your platform is supported

Using wires, connect the 7-Segment Display as shown below to your Raspberry Pi.

  • Raspberry Pi 3.3V to 7-Segment Display IO
  • Raspberry Pi 5V to 7-Segment Display VIN
  • Raspberry Pi GND to 7-Segment Display GND
  • Raspberry Pi SCL to 7-Segment Display SCL
  • Raspberry Pi SDA to 7-Segment Display SDA

To wire up the display using the STEMMA QT port, if you have a board with STEMMA QT connected to the 40-pin header, you can just use a STEMMA QT cable. If you want to connect the display directly to the header pins, you can just use a cable such as:

Angled shot of JST SH 4-pin Cable with Premium Female Sockets.
This 4-wire cable is a little over 150mm / 6" long and fitted with JST-SH female 4-pin connectors on one end and premium female headers on the other. Compared with the chunkier...
Out of Stock

Then connect the 7-Segment Display as shown below to your Raspberry Pi:

  • Raspberry Pi 3.3V to STEMMA QT red wire
  • Raspberry Pi GND to STEMMA QT black wire
  • Raspberry Pi SCL to STEMMA QT yellow wire
  • Raspberry Pi SDA to STEMMA QT blue wire


You'll need to install the Adafruit_Blinka library that provides the CircuitPython support in Python. This may also require enabling I2C on your platform and verifying you are running Python 3. Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready!

Python Installation of HT16K33 Library

Once that's done, from your command line run the following command:

  • pip3 install adafruit-circuitpython-ht16k33

If your default Python is version 3 you may need to run 'pip' instead. Just make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!

If that complains about pip3 not being installed, then run this first to install it:

  • sudo apt-get install python3-pip

Pillow Library

We also need PIL, the Python Imaging Library, to allow using text with custom fonts. There are several system libraries that PIL relies on, so installing via a package manager is the easiest way to bring in everything:

  • sudo apt-get install python3-pil

That's it. You should be ready to go.

This guide was first published on Jul 29, 2012. It was last updated on Jul 23, 2024.

This page (Python Wiring and Setup) was last updated on Mar 08, 2024.

Text editor powered by tinymce.