Source: https://mokxi.com/libraries/adafruit-ledbackpack
Updated: 2026-11-22

Libraries / Displays

Arduino library · Displays

# Adafruit LED Backpack: the HT16K33 seven-segment display

Yes, with limits. You can use the Adafruit LED Backpack Library online in Mokxi with nothing to install, and the sketch runs in your browser against the simulated part (Four-digit display, HT16K33 backpack). Part of it is not simulated, and the notes below say which. The example below, "Air quality monitor", runs on the Arduino Uno R3.

Run the example in Mokxi See the calls

Built in on Mokxi: #include <Adafruit_LEDBackpack.h> and it builds, with nothing to install. Free, and no account needed.

## What Adafruit LED Backpack Library does

Adafruit’s LED backpacks put an HT16K33 driver behind a display so it needs only the two I2C wires. The library has a class for each kind: Adafruit_7segment for the four-digit clock display, Adafruit_8x8matrix and Adafruit_BicolorMatrix for square grids, Adafruit_24bargraph and Adafruit_AlphaNum4 for fourteen-segment letters. Several backpacks can share one bus at addresses 0x70 to 0x77.

Nothing you write reaches the display at once. print(), writeDigitRaw() and drawColon() change a buffer in the board’s RAM, and writeDisplay() sends the whole buffer in one I2C transfer. On the seven-segment backpack the buffer has five positions: 0 and 1 are the left digits, 2 is the colon, and 3 and 4 are the right digits, which is why raw writes skip position 2.

Mokxi’s HT16K33 part is the four-digit seven-segment backpack. The matrix, bar graph and alphanumeric classes compile and send the chip the same bytes the real library would, but no part draws them as a grid or as letters. The runnable project is an air quality monitor that shows CO2, temperature and humidity on the seven-segment display.

Library Manager name | Adafruit LED Backpack Library

Author | Adafruit

Include | #include <Adafruit_LEDBackpack.h>

Boards | every board Mokxi compiles for but ATtiny85

In the simulator | Runs, with a gap the note below names.

Parts it drives | Four-digit display, HT16K33 backpack

## Install it

It builds on every board Mokxi compiles for but ATtiny85.

In Mokxi it is built in: #include <Adafruit_LEDBackpack.h> and the sketch compiles, with no download, no zip and no Library Manager.

On a real board, install "Adafruit LED Backpack Library" by Adafruit from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add Adafruit LED Backpack Library to lib_deps in PlatformIO. Mokxi follows the calls of release 1.5.1, so a sketch written here builds there too.

What to know in the simulator: Mokxi’s HT16K33 part is the seven-segment backpack: the matrix, bar graph and alphanumeric classes send the chip what upstream sends, and no part draws them. The fourteen-segment letters are Mokxi’s own.

- ESP32-C3
- Arduino Uno
- Arduino Nano
- Arduino Mega 2560
- Arduino Leonardo
- SparkFun Pro Micro
- Arduino Micro
- ESP32-C6
- WCH CH32V003
- Raspberry Pi Pico
- Raspberry Pi Pico W
- Seeed XIAO SAMD21
- STM32
- STM32 Nucleo-F411RE
- STM32 Blue Pill
- micro:bit V2
- Arduino Uno R4
- ESP32 DevKit
- ESP32-S3-DevKitC-1
- ESP8266 NodeMCU
- Arduino Pro Mini 3.3 V
- Seeed XIAO ESP32-C3
- ESP32-C3 SuperMini
- Seeed XIAO ESP32-C6
- ESP32-DevKitC V4
- LOLIN32 Lite
- Wemos D1 R32
- Cheap Yellow Display
- TTGO T-Display
- Seeed XIAO ESP32-S3
- ESP32-S3-CAM
- Arduino Nano ESP32
- Arduino Nano RP2040 Connect
- Seeed XIAO RP2040
- Waveshare RP2040-Zero
- Arduino Uno R4 WiFi

## The calls you will use

In the order a sketch meets them.

### Adafruit_7segment display = Adafruit_7segment()

Makes the four-digit seven-segment backpack. It inherits Print, so print() takes whole numbers, floats and text.

### display.begin(0x70)

Starts the oscillator, turns the display on without blinking and sets full brightness. 0x70 is the address with no jumpers bridged.

### display.print(1234, DEC)

Right-aligns a number in the four digits, in any base up to 16. A number that does not fit shows four dashes.

### display.writeDigitRaw(3, 0x39)

Lights segments directly at one position, segment A in bit 0 to G in bit 6 and the point in bit 7. 0x39 is a C, useful for units like degrees C.

### display.drawColon(true)

Turns the center colon on or off for a clock layout.

### display.writeDisplay()

Sends the buffer to the chip. Call it after every change you want to see.

### display.setBrightness(10)

Brightness from 0 to 15, in sixteen steps of the chip’s own dimming.

### display.blinkRate(HT16K33_BLINK_1HZ)

Makes the chip blink the whole display by itself: HT16K33_BLINK_OFF, _2HZ, _1HZ or _HALFHZ. Good for an alarm that needs no code in loop().

## Example: Air quality monitor

On the Arduino Uno R3. It runs in the browser exactly as printed.

sketch.ino · Arduino Uno R3

Open it in the editor, wired and ready to run · Air quality monitor: the project page

## Common errors and how to fix them

### The display stays dark although print() runs

writeDisplay() is missing. The library only changes its buffer until that call sends it, so add display.writeDisplay() after the last change of each update.

### A raw segment pattern shows up in the wrong digit

Position 2 is the colon, not a digit. The four digits are positions 0, 1, 3 and 4, so the rightmost digit is writeDigitRaw(4, ...).

### Two backpacks on the bus show the same thing

Both are at 0x70. Bridge an address jumper on one of them to move it to 0x71 or higher, then call begin() with that address for the second object.

## Keep going

### Learn

- Arduino 4 Digit 7 Segment Display: Wiring and Code
- I2C Explained: Addresses, Acknowledges and Pull-Ups

### Parts

- Four-digit display, HT16K33 backpack

### More displays libraries

- Adafruit SSD1306
- Adafruit GFX Library
- LiquidCrystal I2C
- LiquidCrystal
- LCD_I2C
- hd44780
- TFT_eSPI
- U8g2
- SevenSegmentTM1637
- OLED_I2C
- Adafruit PCD8544 Nokia 5110 LCD library
- LedController
- DigitLedDisplay

Every built-in library · Open the editor

## Try Adafruit LED Backpack Library without installing anything

Open the example, change the sketch, and keep your version in a free account.

Start building free

Open the editor
