- To control an LED matrix connected to an SPI MAX7219 chip, create the following matrixControl.py script:
#!/usr/bin/python3 # matrixControl.py import wiringpi import time MAX7219_NOOP = 0x00 DIG0=0x01; DIG1=0x02; DIG2=0x03; DIG3=0x04 DIG4=0x05; DIG5=0x06; DIG6=0x07; DIG7=0x08 MAX7219_DIGIT=[DIG0,DIG1,DIG2,DIG3,DIG4,DIG5,DIG6,DIG7] MAX7219_DECODEMODE = 0x09 MAX7219_INTENSITY = 0x0A MAX7219_SCANLIMIT = 0x0B MAX7219_SHUTDOWN = 0x0C MAX7219_DISPLAYTEST = 0x0F SPI_CS=1 SPI_SPEED=100000 class matrix(): def __init__(self,DEBUG=False): self.DEBUG=DEBUG wiringpi.wiringPiSPISetup(SPI_CS,SPI_SPEED) self.sendCmd(MAX7219_SCANLIMIT, 8) # enable outputs self.sendCmd(MAX7219_DECODEMODE, 0) # no digit decode self.sendCmd(MAX7219_DISPLAYTEST, ...