The bicolor bar graph display is demonstrated in the bicolor24_test.py script. This code will light up 3 bars in different colors and then loop through full color all on and all off modes.
# SPDX-FileCopyrightText: 2019 Mikey Sklar for Adafruit Industries
#
# SPDX-License-Identifier: MIT
# Basic example of using the Bi-color 24 segment bargraph display.
# This example and library is meant to work with Adafruit CircuitPython API.
# Author: Carter Nelson
# License: Public Domain
import time
import board
import busio
# Import the Bicolor24 driver from the HT16K33 module
from adafruit_ht16k33.bargraph import Bicolor24
# Create the I2C interface
i2c = busio.I2C(board.SCL, board.SDA)
# Create the LED bargraph class.
bc24 = Bicolor24(i2c)
# Set individual segments of bargraph
bc24[0] = bc24.LED_RED
bc24[1] = bc24.LED_GREEN
bc24[2] = bc24.LED_YELLOW
time.sleep(2)
# Turn them all off
bc24.fill(bc24.LED_OFF)
# Turn them on in a loop
for i in range(24):
bc24[i] = bc24.LED_RED
time.sleep(0.1)
bc24[i] = bc24.LED_OFF
time.sleep(1)
# Fill the entrire bargraph
bc24.fill(bc24.LED_GREEN)
We can easily copy this code onto our Pi's home directory using the 'wget' command and then run it using the following commands.
cd wget https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/master/Matrix_7-Segment_LED_Backpack_Raspberry_Pi/bicolor24_test.py python3 bicolor24_test.py
Page last edited January 22, 2025
Text editor powered by tinymce.