ht16k33_bicolor24_simpletest.py
1 # Basic example of using the Bi-color 24 segment bargraph display. 2 # This example and library is meant to work with Adafruit CircuitPython API. 3 # Author: Carter Nelson 4 # License: Public Domain 5 6 import time 7 8 # Import board related modules 9 import board 10 import busio 11 12 # Import the Bicolor24 driver from the HT16K33 module 13 from adafruit_ht16k33.bargraph import Bicolor24 14 15 # Create the I2C interface 16 i2c = busio.I2C(board.SCL, board.SDA) 17 18 # Create the LED bargraph class. 19 bc24 = Bicolor24(i2c) 20 21 # Set individual segments of bargraph 22 bc24[0] = bc24.LED_RED 23 bc24[1] = bc24.LED_GREEN 24 bc24[2] = bc24.LED_YELLOW 25 26 time.sleep(2) 27 28 # Turn them all off 29 bc24.fill(bc24.LED_OFF) 30 31 # Turn them on in a loop 32 for i in range(24): 33 bc24[i] = bc24.LED_RED 34 time.sleep(0.1) 35 bc24[i] = bc24.LED_OFF 36 37 time.sleep(1) 38 39 # Fill the entrire bargraph 40 bc24.fill(bc24.LED_GREEN)