MAX72xx series (MAX7219 and MAX7221) LCD driver can control up to 8 seven segment LED displays or 64 individual LEDs (great for 8×8 LED matrix).  However you can’t just connect 64 LEDs directly as chip only has 24 pins, and only 16 of them are meant to be connected to LED displays.  That’s why its important to connect individual LED pins into a matrix.

MAX72XX and LED Multiplexing

This driver IC has 8 “digit” pins (0-7) and 8 “segment” pins (SegA-SegF and SegDP).  If you think of digit pins as rows and Segment pins as individual LEDs, you can see how 64 LEDs can be used.  Because each row can have up to 8 LEDs all you do is connect cathodes of these 8 LEDs together and then to a digit pin (i.e. DIG0) of MAX72xx chip.   Anode of each of 8 LEDs then connected to single Segment lead of the IC.

Protected Area

This content is password-protected. Please verify with a password to unlock the content.

If you have 64 LEDs you just connected them to IC with only 16 wires!  If you want to connect even more you will need to add another MAX72xx chip, but that’s beyond the scope of this tutorial.  In our case we only have 10 LEDs, so we will be using DIG0, DIG1 and all SEG pins. Total pins used 10!

Before we start soldering, let’s see if everything is working on breadboard

  • Start by placing MAX72xx chip on the board.
  • Connect GND Pins 4 and 9 to the ground.
  • Connect Pin 19 (VCC) to +5V
  • Place 30K resistor between Pin 18 (ISET) and 19 (VCC)
  • Connect pin 1 (DIN) to Arduino’s D9
  • Connect pin 12 (LOAD) to Arduino’s D7
  • Connect pin 13 (CLK) to Arduino’s D8

Protected Area

This content is password-protected. Please verify with a password to unlock the content.

the sketch

// V4 2014-01-21 (Improved logic of bit shifting for last 2 LEDs)
// Notes: 33K Rset resistor must! Also decoupling 10uF polarized and .1uf ceramic capacitors needed on VCC line

#include "LedControl.h"

#define MAX_LED 10 // Number of LEDs in bar graph array
#define MAX_BRIGHTNESS 15 // 0-15 LED brightness
#define pauseLED 50
#define BLINK_SPEED 250 // Speed of blinking
#define LED_TIMEOUT 10000 // Time out after which LED bar turns off

boolean isOn = true;
boolean isSleeping = false;
boolean okBlink = false; // Triggers blinking
unsigned long lastBlink = 0; // Last time LEDs blinked
unsigned long lastOn = 0; // Last time LED Bar was turned off

byte blinkCount = 0; // Counts blinks/flashes
byte Bars = 5; // Temp. number of barts to light up

/*
 pin 9 is connected to the DataIn 
 pin 8 is connected to the CLK 
 pin 7 is connected to LOAD 
 We have only a single MAX72XX.
 */
LedControl lc = LedControl(9,8,7,1);

void setup() {
    Serial.begin(115200);
    lc.shutdown(0,false);

// Set the brightness to a medium values
    lc.setIntensity(0,MAX_BRIGHTNESS);

// and clear the display
    lc.clearDisplay(0);
    LEDBarDisplay (Bars);
    okBlink=true;
    delay (1000);
    Serial.println ("ready");
}

void loop() { 

  chaseLED();
}

Protected Area

This content is password-protected. Please verify with a password to unlock the content.

End Of Post