Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
65 lines (52 sloc) 3.42 KB


Single/bi/tri-color LED Matrix PWM driver for arduino (direct IO or Shift Register connected)

Blog post with video:

This code implements equivalent and additional functionality from what you get from Adafruit's

Adafruit sells bi color 8x8 LED matrices with an I2C interface. They are easy to program with the adafruit library, but doing per pixel PWM is virtually impossible, which means you only get 3 colors: Red, Green, and Orange (red+green). See:

I wrote this driver to control raw LED matrices which is a lot more work, but provides more flexibility. My code allows you to connect the matrices directly to any arduino IO pins or via shift registers for the columns (adding shift register support for rows is easy, but I haven't done it yet since it makes the code slower and I didn't need to save extra IO pins)

Here is how my approach differs from Adafruit's: Summary: if you don't need to mix color intensities (3 colors is enough vs 256), buy adafruit's solutions, they are much simpler for you and leave CPU time and IO pins on the arduino. But if you already have raw LED matrices with no driver chip, this code is for you. Note that if you buy a MAX7219 driver chip, you'll have the same problem than the adafruit solution and will not be able to mix colors intensities. I've found that this newer chip can do bi color and 4 step PWM (not as good as my code, but not bad). You may still want to look at a MAX6960.

Pluses for my solution:

Minuses for my solution:

  • my driver does all the work in software, and requires sequencing interrupts every 150, 300, 600, 1200 microseconds on the arduino (I use binary code modulation to avoid having 16 interrupts at 150us, and only have 4 interrupts at increasing frequencies. See
  • obviously my solution requires more IO pins than adafruits (at least 5 pins for 2 colors and 6 pins for 3 colors, or many more if you don't use shift registers for extra speed)
  • my driver also uses Timer1 (which means you can't easily use PWM 9 and 10)

Required libraries: