code.py
 1  # SPDX-FileCopyrightText: 2019 Mikey Sklar for Adafruit Industries
 2  #
 3  # SPDX-License-Identifier: MIT
 4  
 5  import time
 6  import board
 7  import busio
 8  from adafruit_ht16k33 import segments
 9  
10  # Create the I2C interface.
11  i2c = busio.I2C(board.SCL, board.SDA)
12  
13  # Create the LED segment class.
14  # This creates a 7 segment 4 character display:
15  display = segments.Seg7x4(i2c)
16  
17  # Clear the display.
18  display.fill(0)
19  
20  # Can just print a number
21  display.print(42)
22  time.sleep(1)
23  
24  # Set the first character to '1':
25  display[0] = '1'
26  # Set the second character to '2':
27  display[1] = '2'
28  # Set the third character to 'A':
29  display[2] = 'A'
30  # Set the forth character to 'B':
31  display[3] = 'B'
32  time.sleep(1)
33  
34  numbers = [0.0, 1.0, -1.0, 0.55, -0.55, 10.23, -10.2, 100.5, -100.5]
35  
36  # print negative and positive floating point numbers
37  for i in numbers:
38      display.print(i)
39      time.sleep(0.5)
40  
41  # print hex values, enable colon
42  for i in range(0xFF):
43      display.fill(0)
44      display.print(':')
45      display.print(hex(i))
46      time.sleep(0.25)