Skip to content

Commit 1eb2dad

Browse files
committed
bicolor24_test.py runs clean, linted, python3 compat
1 parent 2c83e3b commit 1eb2dad

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
import board
8+
import busio
9+
10+
# Import the Bicolor24 driver from the HT16K33 module
11+
from adafruit_ht16k33.bargraph import Bicolor24
12+
13+
# Create the I2C interface
14+
i2c = busio.I2C(board.SCL, board.SDA)
15+
16+
# Create the LED bargraph class.
17+
bc24 = Bicolor24(i2c)
18+
19+
# Set individual segments of bargraph
20+
bc24[0] = bc24.LED_RED
21+
bc24[1] = bc24.LED_GREEN
22+
bc24[2] = bc24.LED_YELLOW
23+
24+
time.sleep(2)
25+
26+
# Turn them all off
27+
bc24.fill(bc24.LED_OFF)
28+
29+
# Turn them on in a loop
30+
for i in range(24):
31+
bc24[i] = bc24.LED_RED
32+
time.sleep(0.1)
33+
bc24[i] = bc24.LED_OFF
34+
35+
time.sleep(1)
36+
37+
# Fill the entrire bargraph
38+
bc24.fill(bc24.LED_GREEN)

0 commit comments

Comments
 (0)