Speeding up your SPI MAX7219 LED displays when using Arduino and LedControl Library

In preparation for the arrival of my GPSDO[1], I’m doing a quick build of an “Atomic Clock” display to have above my lab equipment. I’m using a cheap, small eight digit red LED SPI-controlled display. It uses the MAX7219 controller that I got from eBay for next to nothing. I plan to parse the RS232 information from the GPSDO unit and display the exact time. I’ll also post error messages if the GPS signal lock gets lost.

I’ve done a quick prototype using an Arduino Uno, but I plan to try to get an Attiny85 to work as the controller when I’ve finished the parser and the rest of the software.

After doing some research, naturally, there was a library available to connect to my LED display called LedControl. It’s part of the standard Arduino libraries (in the download section). But when I checked the code, it uses the Arduino routines to shift out the SPI data to the display. It’s great if you want to be able to use any pins to connect to the screen, but using Arduino’s bit manipulation tools for “bit-banging” the display is slow.

How slow? Well, I modified the code for the library, so it uses hardware SPI instead. Here you can see the difference.

https://www.youtube.com/watch?v=c-LFL6rY_OY&feature=youtu.be

My uneducated guess is something like 40–100x the speed compared to the original code. So if you drive a lot of displays in series and are using the LedControl library, you can speed things up by using my library instead. The only downside is that you need to use the designated hardware SPI pins. You can find the modified hardware SPI version of LedControl here. I’m going to fiddle around a bit and add some more features when I get the time.


  1. GPS Disciplined Crystal Oscillator, in my case a Trimble with a dual ovenized crystal oscillator.  ↩