def arrowMatrix(): matrix.fill(0) matrix.auto_write = False matrix[0,4] = 1 matrix[1,3] = 1 matrix[1,5] = 1 matrix[2,2] = 1 matrix[2,4] = 1 matrix[2,6] = 1 matrix[3,1] = 1 matrix[3,4] = 1 matrix[3,7] = 1 matrix[4,4] = 1 matrix[5,4] = 1 matrix[6,4] = 1 matrix[7,4] = 1 matrix.show() matrix.auto_write = True
i2c = busio.I2C(board.SCL, board.SDA) # Create the matrix class. # This creates a 16x8 matrix: matrix = matrix.Matrix16x8(i2c) # Or this creates a 16x8 matrix backpack: #matrix = matrix.MatrixBackpack16x8(i2c) # Or this creates a 8x8 matrix: #matrix = matrix.Matrix8x8(i2c) # Or this creates a 8x8 bicolor matrix: #matrix = matrix.Matrix8x8x2(i2c) # Finally you can optionally specify a custom I2C address of the HT16k33 like: #matrix = matrix.Matrix16x8(i2c, address=0x70) # Clear the matrix. matrix.fill(0) # Set a pixel in the origin 0, 0 position. matrix[0, 0] = 1 # Set a pixel in the middle 8, 4 position. matrix[8, 4] = 1 # Set a pixel in the opposite 15, 7 position. matrix[15, 7] = 1 time.sleep(2) # Draw a Smiley Face matrix.fill(0) for row in range(2, 6): matrix[row, 0] = 1
# Import all board pins. import board import busio # Import the HT16K33 LED matrix module. from adafruit_ht16k33 import matrix # Create the I2C interface. i2c = busio.I2C(board.SCL, board.SDA) # Create the matrix class. # This creates a 16x8 matrix: matrix = matrix.Matrix16x8(i2c) # Or this creates a 8x8 matrix: #matrix = matrix.Matrix8x8(i2c) # Or this creates a 8x8 bicolor matrix: #matrix = matrix.Matrix8x8x2(i2c) # Finally you can optionally specify a custom I2C address of the HT16k33 like: #matrix = matrix.Matrix16x8(i2c, address=0x70) # Clear the matrix. matrix.fill(0) # Set a pixel in the origin 0,0 position. matrix[0, 0] = 1 # Set a pixel in the middle 8, 4 position. matrix[8, 4] = 1 # Set a pixel in the opposite 15, 7 position. matrix[15, 7] = 1
def clear(matrix): matrix.fill(0) matrix.show()