5 Replies Latest reply on Mar 8, 2016 8:13 AM by DiegoV_Intel

    Using MAX7219 LED Driver With Intel Edison




      I am trying to drive some 7 segment displays with the Edison (using Arduino expansion board) and the MAX7219 shift register. I am 99% sure I got the SPI bus up an running using the echo commands per the hardware guide, but I am not sure how to align the clock speed between the Edison and MAX7219. I am using the following LEDS:




      I am using the LEDControl.h library in my Arduino sketch as it worked quickest with the Uno. My problem is that I am new to SPI and not sure how to adjust the clock speed to get the Edison aligned with the MAX7219. Does anyone have a suggestion on doing this in the Arduino environment? Do I need to make some type of mod to the LEDControl.h library? Any advice would be much appreciated. Arduino sample code I am using is below:



      // Initialization for Small 7 Segment Displays

      #include "LedControl.h"

      LedControl lc=LedControl(12,11,10,1);


      void setup() {


        /* Set the brightness to a medium values */


        /* and clear the display */





      void loop() {


        // Strike Test








      void strikeZero(){





      void strikeOne(){





      void strikeTwo(){




        • 1. Re: Using MAX7219 LED Driver With Intel Edison

          Hi Frank_1985,


          I'm curious about what echo commands you are referring to. I've checked the LedControl.h library available here: GitHub - wayoda/LedControl: An Arduino library for MAX7219 and MAX7221 Led display drivers and it seems that you don’t have to set anything with the SPI; the library does it for you. However, I could be wrong since I haven't tested it yet.


          Anyhow, how are you setting the SPI? Are you using the Arduino environment for it?




          • 2. Re: Using MAX7219 LED Driver With Intel Edison

            Hi Diego,


            Thanks for the response. My understanding from the Intel Edison Kit for Arduino Hardware guide is that (from section 11.7 ) in order to Configure IO10 through IO13 for SPI connectivity, you have to configure numerous GPIOs using echo commands on the Linux side...for example:


            # echo 111 > /sys/class/gpio/export


            Since the guide says to do this, I assumed that these pins were not configured for SPI connectivity by default. This has nothing to do with my Arduino code or using the LEDcontrol library, I was just under the impression from the hardware guide that the board is not configured for SPI connectivity out of the box and it requires making these commands on the Linux side before these pins are ready for SPI.


            So in response your question about how am I setting SPI, the answer is that I am not. I have only configured the Edison for SPI connectivity per the directions in the Hardware Guide. After doing this, uploading the sketch with the default LEDcontrol.h library still does not work on the Edison. My guess is that I need to change "byte spidata[16]" (shown below) in the LedControl.h file. Once again I am new to SPI, but my guess is that "byte spidata[16]" shown in the code below corresponds to the 16MHz clock speed of the Arduino? Would this mean that I can just change the "16" to "100" to match up with the 100MHz clock in the Edison? I tried that and it did not work but I will try again.


            Also, I wonder if the clockspeed is being divided somewhere in the LEDcontrol library? The Uno has a 16MHz clock and the datasheeet for the MAX7219 indicates the maximum for incoming data is 10MHz.


            Any thoughts or comments would be much appreciated. Thanks!






            class LedControl {
              private :
               /* The array for shifting the data to the devices */
              byte spidata[16];
               /* Send out a single command to the device */
               void spiTransfer(int addr, byte opcode, byte data);
               /* We keep track of the led-status for all 8 devices in this array */
              byte status[64];
               /* Data is shifted out of this pin*/
               int SPI_MOSI;
               /* The clock is signaled on this pin */
               int SPI_CLK;
               /* This one is driven LOW for chip selectzion */
               int SPI_CS;
               /* The maximum number of devices we use */
               int maxDevices;
            • 3. Re: Using MAX7219 LED Driver With Intel Edison

              Hi Frank_1985,


              You are correct. That's the way you should configure the SPI interface, however, when using an Arduino sketch, the SPI interface is automatically configured so there is no need to run the echo commands.


              Regarding the LedControl.h library, if it works fine on the Arduino UNO but it doesn't work on Edison, the issue might be that the library is not compatible with the Edison architecture.


              The line "byte spidata[16]" is not related to the SPI clock. It defines a byte array of 16 values/positions. If you change "16" to "100" you are defining an array of 100 values/positions.


              As I said above, this library might not be compatible with Edison. I recommend you to try to write a new library for the LED driver. You could use the SPI library available in the Arduino IDE which is Edison compatible. If you are using the Arduino IDE 1.6.0, you can check the SPI.h/SPI.cpp files in the following directory: C:\...\arduino-1.6.0+Intel\hardware\intel\i686\libraries\SPI\src




              • 4. Re: Using MAX7219 LED Driver With Intel Edison



                Thanks again for the response. I guess what is confusing me is the fact that there is an Intel sponsored Instructable that gave me the impression that the LedControl.h library does work with the Edison. The main reason I started working on this project using the MAX7219 driver and the Intel Edison was because I felt rather assured that the LedControl.h library would work based on the Instructable (which Intel also seems to have sponsored).


                After reviewing the Instructable again, I did find it odd that the Arduino sketch for was set to the Arduino Yun in the IDE when I downloaded the .Ino file. Watching the video again, it looks like they never even show the LED matrix being used with the Edison. Instead they have it connected to an Uno when they are playing Pong. This all seems very misleading. The link to the Instructable is below.


                Controlling An LED Matrix - All


                Do you have any Arduino Sketches using the SPI library that you could forward along that you believe will work instantly with the MAX7219 driver?


                Thanks Again

                • 5. Re: Using MAX7219 LED Driver With Intel Edison

                  Hi Frank_1985,


                  You're right, I've checked the Instructable and it looks like everything should work on Edison but I tested the MatrixStaticAnimation code available and I couldn't get any signal on pins 10, 11 and 12. Then I tested the LCDemo7Segment example code available in the LedControl library and again, I got no response on pins 10, 11, 12. It seems that this library doesn't work on Edison.


                  Unfortunately, I'm not aware of any sketch for the MAX7219 driver. You would have to write one for your application. I recommend you to check the examples available in the Arduino IDE for the SPI library. You might find them useful to see what methods can be used in the SPI communication.