I am trying to hook up an 8x8 LED matrix to my Raspberry Pi 4B. I connected it to SPI1 because I am already using SPI0 for another device. Here are the pins I am using:

CLK - GPIO 20 CS - GPIO 16 DIN - GPIO 18

According to my readings, this means the device can be controlled through spi port 1 device 2. The issue that I have is that 50% of the LEDs are permanently on. Here is a picture of what it looks like.


I tried to clear the device using the code below but nothing happens. When I try to display something, only the LEDs that are not permanently on turn on. Any idea on what I am doing wrong?

from luma.led_matrix.device import max7219
from luma.core.interface.serial import spi, noop
from luma.core.render import canvas
from luma.core.virtual import viewport
from luma.core.legacy import text, show_message
from luma.core.legacy.font import proportional, CP437_FONT, TINY_FONT, SINCLAIR_FONT, LCD_FONT
serial = spi(port=1, device=2, gpio=noop())
device = max7219(serial, width=8, height=8, block_orientation=-90)

  • 1
    Have you got the matrix round the right way in the sockets on the circuit board behind it? Mount it upside down and you'll get the always on problem.
    – Dougie
    Mar 8, 2020 at 15:37
  • 1
    It's hard to know because it came already soldered. How can I check? Mar 8, 2020 at 15:40
  • 1
    Hey, I wanted to thank you. I had not realized that the actual matrix could be switched without desoldering, because the whole thing came in one piece. It now works! I don't know if this is a known thing, but it could help others. If you want to post it as an answer, I will gladly select it. Mar 8, 2020 at 15:51
  • 1
    I've added that as an answer. Can you tick the accepted answer box.
    – Dougie
    Mar 8, 2020 at 15:55
  • 1
    Done! Thanks so much, you saved me 10 bucks and some soldering. Glad I did not waste this device. Also, I looked at your pic and I think I recognize you. I saw you help people on different platforms! Mar 8, 2020 at 16:00

1 Answer 1


Switch the matrix round. Pull it from the sockets on the circuit board. Turn through 180° and re-insert it. LED matrices have a polarity and it's a common problem to get LEDs lit unexpectedly if the polarity is reversed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.