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 14 segment 4 character display: 15 display = segments.Seg14x4(i2c) 16 17 # Clear the display. 18 display.fill(0) 19 20 # set brightness, range 0-1.0, 1.0 max brightness 21 display.brightness = 1.0 22 23 # show phrase on alphanumeric display 24 message = "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG" 25 count = 0 26 27 # print one character at time with short sleep 28 # creates smooth scrolling effect 29 while count < len(message): 30 display.print(message[count]) 31 count += 1 32 time.sleep(0.3) 33 34 # Can just print a number 35 display.print(42) 36 time.sleep(1) 37 38 # Set the first character to '1': 39 display[0] = '1' 40 # Set the second character to '2': 41 display[1] = '2' 42 # Set the third character to 'A': 43 display[2] = 'A' 44 # Set the forth character to 'B': 45 display[3] = 'B' 46 time.sleep(1) 47 48 numbers = [0.0, 1.0, -1.0, 0.55, -0.55, 10.23, -10.2, 100.5, -100.5] 49 50 # print negative and positive floating point numbers 51 for i in numbers: 52 display.print(i) 53 time.sleep(0.5) 54 55 # print hex values, enable colon 56 for i in range(0xFF): 57 display.fill(0) 58 display.print(':') 59 display.print(hex(i)) 60 time.sleep(0.25)