Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jaylandro/1b34da136a99ea0eaed62830abd78983 to your computer and use it in GitHub Desktop.
Save jaylandro/1b34da136a99ea0eaed62830abd78983 to your computer and use it in GitHub Desktop.
Use a 2 dimensional array to display images on a 16x8 led matrix display (Adafruit, QtPy, LED backpack) CircuitPython
# Import all board pins.
import time
import board
import busio
from adafruit_ht16k33 import matrix
i2c = busio.I2C(board.SCL, board.SDA)
matrix = matrix.MatrixBackpack16x8(i2c)
matrix.fill(0)
biglove = [
[0,1,1,0,0,1,1,0],
[1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,0],
[0,0,1,1,1,1,0,0],
[0,0,0,1,1,0,0,0],
[0,0,0,0,0,0,0,0],
]
smalllove = [
[0,0,0,0,0,0,0,0],
[0,0,1,0,0,1,0,0],
[0,1,1,1,1,1,1,0],
[0,1,1,1,1,1,1,0],
[0,0,1,1,1,1,0,0],
[0,0,0,1,1,0,0,0],
[0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0]
]
def drawArray(arr2d, offset = 0):
for i in range(len(arr2d)):
for j in range(len(arr2d[i])):
matrix[i + offset, j] = arr2d[i][j]
while True:
drawArray(smalllove)
drawArray(smalllove, 8)
time.sleep(2)
drawArray(biglove)
drawArray(biglove, 8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment