-
Notifications
You must be signed in to change notification settings - Fork 4
Home
Welcome to the LedMatrixSPI wiki!
An Arduino Uno library for controlling multiple 8x8 LED displays in a matrix style format using the MAX7219/7221 display drivers. It does not support 7-segment displays. The library was written using direct pin and register manipulation, so should work for any ATmega328 model Arduino. However, with only a few minor changes it can be adapted to other MCUs.
The library was written after building a 48x32 LED dot matrix, and the LedControl library was simply not fast enough. Initially I wrote the LedMatrix library, which uses a software SPI implementation. It was significantly faster, but displays with more than 16 drivers started getting slow. This is because the MAX72XX IC use a cascading data protocol which means in order to update a single LED, the entire display needs to be updated. So the more 8x8 displays you have, the slower the refresh rate becomes.
For example, updating a single row of leds on a single MAX72XX driver requires a 2-byte data packet. Therefore, to update all 8 rows requires 16 bytes. If the MCU requires 5 clock cycles (just guessing) to send one bit of data, then 16 bytes takes 1,280 clock cycles (plus some overhead for the code to send the data, but we'll ignore that for now). Therefore, updating 16 displays takes 20,480 clock cycles. If the Arduino's SPI runs at 8MHz, sending 20,480 bits takes approx 1/400th of a second. So 16 displays has a refresh rate of about 400 Hz. Essentially then, every time you double the number of displays, you halve the refresh rate.
Note: I have no idea if these numbers are accurate, but it gives you a good idea.
The LedMatrix and LedMatrixSPI libraries are identical except that this library is much faster, but requires you to use the Arduino's SPI pins. The LedMatrix library allows you to specify the pins used.
NOTE: The library can handle up to 32 rows and 32 columns of 8x8 displays (1,024 8x8 displays or 256 x 256 leds); however, due to display buffering it's unlikely the MCU will have sufficient memory to support more than 180 8x8 displays.