Using a MAX7219/MAX7221 LED display driver with a netduino

LED Matrix Glow

In a previous post, I described how to drive an LED matrix relying on persistence of vision. While beautifully minimalist, this method has drawbacks: it requires 11 digital pins on the netduino and takes constant CPU cycles to refresh the matrix. This can potentially put tough resource constraints on the rest of the application.

This is where a chip like the MAX7219/MAX7221 LED display driver comes in handy: all you need to do is to send it the data that you want to display over SPI and it will drive LEDs without further involvement from the micro controller.

The chip offers 2 display modes: ‘Decode Mode’ is intended to manage 7 segment displays (plus a dot) and another which displays raw bitmaps instead, perfect for controlling an 8×8 LED matrix.

Multiple MAX72xx chips can be daisy-chained together to form larger displays as well.

Being a popular chip, a great deal has been written about the Max7219 and after you familiarize yourself with the datasheet, you should check out this article on the Arduino Playground and come back here when you’re done.

Connecting the MAX72xx to the netduino

Here are the hardware components that you’ll need:

  • 1 Max72xx chip
  • 1 monochrome LED matrix (for example)
  • 1 Logic-level shifter (DigiKey) (optional: see note below)
  • 1 10K resistor minimum
  • 1 100 uF capacitor
  • 1 0.1 uF ceramic capacitor
  • many hookup wires (as short as possible)

Note: The MAX72xx requires 3.5 volt logic levels minimum and because the netduino uses 3.3 volt logic level on its digital output pins, you may need to place a logic-level shifter between the netduino SPI interface and the Max72xx SPI interface. Check out this article if you’re not sure how this works.

While the Max72xx SPI clock can go up to 10 MHz based,  I was unable to get stable communications above 2 MHz when using the MAX7219 with a logic-level shifter. Without the shifter, SPI @ 10 MHz works flawlessly but because this is out of the chip’s specifications, so your mileage may vary.

The following summarizes the connections. It doesn’t matter which pins you choose on the logic-level shifter provided that they’re matching low-level input/high-level output pins.

  • SPI CLK: netduino pin 13 -> Logic-level shifter -> Max72xx pin 13 (CLK)
  • SPI MOSI: netduino pin 11 -> Logic-level shifter -> Max72xx pin 1 (DIN)
  • SPI CS: netduino pin 10 -> Logic-level shifter -> Max72xx pin 12 (LOAD/CS)

Note: the MAX72xx is extremely sensitive to EMI and power fluctuations. So, be sure to:

  • Place the capacitors as close as possible to the V+ and GND pins of the chip
  • Connect both GND pins to ground
  • Use the shortest possible hookup wires

If EMI is an issue, reducing the speed for the SPI bus and/or using shorter hookup wires may help. If you still have EMI issues, the MAX7221 is likely the right alternative.

Connecting the Max72xx to the LED matrix

The LED matrix that I’m using is wired like this:

LED matrix

Connecting it to the MAX72xx is straight forward:

  • The MAX72xx’s SEG pins correspond to the columns of the LED matrix
  • The MAX72xx’s DIG pins correspond to the rows on the LED matrix

Max72xx -> LED matrix Wiring

Using the netduino.helpers Max72xx C# driver

The C# driver attempts to stick to the Max72xx datasheet as closely as possible. It presents properties matching the various registers of the chip and a simple overloaded ‘Display’ method. Be sure to check out the unit tests in the /Samples for usage details.

Max72xx C# Interface

Action shot

Happy hacking!



  1. Mario Vernari · March 13, 2011

    Hi Fabien.
    Nice work, indeed.
    Just a couple of things that could be useful.
    The first is that probably the level shifter is not mandatory. Even the Maxim’s sheet indicates a minimum high voltage of 3.5V, I guess that it should work anyway. I have done it with a 74HC595 powered at +5V and it works OK.
    The second thing is about the length of wiring. The problems of SPI communication are not because EMIs, I think, but the impedance of wiring instead. You may have some better result if you twist the data+clock wires together: I think there will no problem even to 10MHz (as long you don’t exceed 5-10″ in length).

    • Fabien Royer · March 13, 2011

      Thanks Mario. 🙂
      I’ll definitely try twisting the CLK/DATA wires together and will report my findings here.

      • Fabien Royer · March 17, 2011

        I forgot to mention in my earlier comments: removing the logic-level shifter allowed me to bump up the speed to 10 MHz, even w/o twisting CLK/DATA 🙂


    • Fabien Royer · March 16, 2011

      Hey Mario,

      I tested w/o the logic-level shifter tonight and everything worked fine.
      This strays from the chip’s specifications though, so it may not always work. It also appears that the SparkFun logic-level shifter doesn’t keep up at higher frequencies.


  2. Pingback: Windows Client Developer Roundup 063 for 3/14/2011 - Pete Brown's
  3. Mark Stevens · March 14, 2011

    Timely, I| was just wiring up my MAX7219 to a 4 digit seven segment display. This will help a lot.


    • Mark Stevens · March 16, 2011

      I have recently tried this library with a 4 digit, 7 segment display and experienced some problems with the display. The chip appears to be turning the LEDs on all the time. So in test mode they turn on and are bright but when test mode is exited they are still on – just very dim.

      Did you experience this?


      • Fabien Royer · March 16, 2011

        That’s very odd. I haven’t experienced that problem at all.
        Can share your code? I can see if I can get a repro of your issue.
        Also, be aware that we updated the interface of the driver a bit (got rid of the write-only properties in favor of functions with the same names) after running ReSharper on the code.

  4. Mark Stevens · March 18, 2011

    I’m beginning to think I’ve damaged the chip trying to get this to work. I replaced your main program in the samples with:

    _max.Shutdown = Max72197221.ShutdownRegister.ShutdownMode;
    _max.Shutdown = Max72197221.ShutdownRegister.NormalOperation;

    And now I do not get the dimming I get one blank digit followed by three 9’s and the decimal point. Nothing seems to change the display.

    Logic analyser is showing the right commands going over SPI. Wiring is good – double checked that.

    Thanks for the reply,

    • Fabien Royer · March 19, 2011

      Something is definitely wrong hardware-wise here.
      Are you working on a breadboard or have you soldered things together?

      • Mark Stevens · March 19, 2011

        I’m still on breadboard at the moment.

  5. Pingback: Driving a LED matrix from a Netduino one more time: The Right Way
  6. Pingback: Silverlight Developer » Blog Archive » 4 Digit, 7 Segment Display – Part 1 – Ouput a Byte
  7. Courtney Wilson · August 3, 2011


    I’ve just started using your C# library for the Max7219 (thanks for making it). I’ve wired up an led matrix (currently 4 columns, 3 rows of leds). When I plug in the power, all of the led’s light up immediately and they stay on. My code builds and runs but seems to have no effect on the matrix. It seems like the spi is having no effect on the matrix whatsoever (in fact disconnecting the clock, cs and mosi lines do not affect anything at all). Have you run across this before? Any thoughts on where I might start looking to find the problem?



    • Fabien Royer · August 3, 2011

      Hi Courtney,

      Yes, I know exactly what you’re talking about.
      This behavior is caused by the Netduino switching all of its outputs to ‘high’ on power-up. The Max7219 interprets this as a ‘test mode’ command and lights up all of the LEDs connected to it. The remedy is simple though: the power to the Max7219 chip needs to be controlled through a PNP transistor by the application on the Netduino.

      Does this help?


      • Courtney Wilson · August 3, 2011

        Thanks for the quick response. I am a long time programmer, not an electrical engineer, although I have tinkered with a few tiny circuits and read a couple of digital electronics books in the distant past.

        From how I read your response, instead of powering the Max chip with 5V directly, instead put a general purpose PNP transistor in line controlled by some unused Netduino IO pin that will switch on the 5V power to the Max chip when I set the Netduino IO port low. So basically I can control when power is first sent to the Max chip IN CODE thus preventing the Max chip from entering its ‘test mode’ on Netduino bootup.

        I have modified the Max/Netduino schematic from Arudino Playground to include this change. Is there way I can post this image (or email it to you), so that you could verify if I have the concept correct?

        Thanks again,

      • Fabien Royer · August 3, 2011

        So basically I can control when power is first sent to the Max chip IN CODE thus preventing the Max chip from entering its ‘test mode’ on Netduino bootup.

        Exactly! 🙂 If you like, you can email me your diagram at froyer67 at

      • Ron Barry · July 7, 2012

        I’m having a similar problem with a MAX7219, but rather than going straight to the PNP transistors, I changed my code so there was a 10 second pause between when setup() was called and when I instantiated the LedControl. I then powered down the arduino, connected the three 7219 inputs to ground and powered it up again. During the 10 second delay, I switched the inputs back to being connected to the output pins on the arduino. This should have the effect of keeping the 7219 out of test mode by preventing it from getting three high inputs while it is starting up, but it should still be able to initialize normally when I allocate the LedControl.

        I’ve swapped out the 7219 for a different one (from the same batch,) swapped out arduinos, checked the connectivity of every wire in my circuit, and my capacitors are only one pin away from the controller. I’m completely out of ideas. What else might cause the LED matrix to come up with all 64 LEDs on as soon as power is applied?



      • Fabien Royer · July 8, 2012

        Hi Ron,

        I don’t have a straight answer for you but I would suggest connecting a logic analyzer to the SPI lines between the Arduino and the Max7219 to see what’s being sent to the chip on power-up. I would double-check the ground plane connections and would ensure that the caps in your circuit provide sufficient power supply decoupling and digital noise isolation.

        I hope this helps.

  8. Courtney Wilson · September 13, 2011


    I’m still having difficulties with getting this Max7219 chip working with the Netduino. I am using the chip to drive up to 64 individual LEDs. I suspect that I am still running into the issue you described previously regarding the Max7219 being stuck in “test mode”. I noticed you updated your unit tests for the Max chip on Netduino Helpers to include an output port (pin D0) to control the PNP transistor that manages the power to the Max chip. Do you have a wiring diagram or explanation of how to wire in the PNP transistor to the circuit?

    Thanks again


    • Fabien Royer · September 13, 2011

      Hi Courtney,

      I’m in the process of building a complete diagram showing how this is all wired up using the PIX-6T4 as the working example. The power to the Max is actually switched using a PNP / NPN transistor combo to deal with voltage differences between control logic (netduino) and power switching (Max @ 5v). Both transistors are saturated in this scenario. Check back the blog soon as I’ll publish the wiring diagram as part of the series on building your own PIX-6T4 console.

      Cheers, -Fabien.

      • Courtney Wilson · September 13, 2011

        Great! I can’t wait to see this article. This Max chip has been a little thorn in my side. I’ve got a 16×2 LCD working, a 64 button shield working, and managed to get 2 SOMO sound modules working together with an electronic mixer and amp circuit two play two sounds simultaneously. Finishing the 64 led Max chip circuit and then getting my 4 Sure Electronics HT1632C Dot Matrix panels working are the last steps in my plan to rule the world.

        Thanks again for your time and I look forward to your article!


      • Fabien Royer · September 19, 2011

        Hi Courtney,

        Check out the docs section on the new PIX-6T4 site. I uploaded the schematics that you’ll need to resolve your issue there. Hope this helps.

  9. Osama Ashaikh · January 27, 2012

    Hi Fabien,
    The new site does not seem to be working, is it possible to send me a copy of the resolved schematics to my email address

    • Fabien Royer · January 28, 2012

      Hi Osama,

      Are you talking about the new PIX-6T4 site? We’ve been having difficulties with the site’s hoster but it’s working fine now 🙂 Check this page:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s