MAX7219 does not respond to code written using LedControl library

I am working on a project that will show the state of votes after pressing a red or green button. The voting state will be shown using two led matrices with 50 leds each, that will light up according to the percentages that had been recorded until that point.
My problem is that any code from the LedControl library that is supposed to control the MAX7219 bears no response. The code I am using is below:

//we have to include the libary 
#include "C:\Users\Adi\Downloads\arduino-1.0.4-windows\arduino-1.0.4\libraries\LedControl\LedControl.h"

// enter the number of LEDs on a side
#define NUM_LEDS  50

//and create the LedControl 
LedControl forDisplay = LedControl(12,11,10,1);
LedControl againstDisplay = LedControl(9,8,7,1);

// pushbutton pins
int buttonForPin = 2;
int buttonAgainstPin = 3;

// button led pins
int forLedPin = 4;
int againstLedPin = 5;

// button state markers
int buttonStateFor = 0;
int buttonStateAgainst = 0;

// amount of data each led holds
double delta = NUM_LEDS/100.0;

// data holders
int totalCount = 0;
int forCount = 0;
int againstCount = 0;

void setup() {
  //wake up the MAX72XX from power-saving mode 
  //set a high brightness for the Leds

  //initialize button pins as input
  pinMode(buttonForPin, INPUT);
  pinMode(buttonAgainstPin, INPUT);

  //initialize led light-up pins
  pinMode(forLedPin, OUTPUT);
  pinMode(againstLedPin, OUTPUT);
  //turn off all the leds



void showResults() {
  // increase total count of people voted


  // calculate the decimal value of people voting for
  double forDecimal = (double)forCount/totalCount;

  // calculate whole number percentage of people voting for
  int forPercentage = forDecimal * 100;

  // turn on the correct number of leds to show percentage
  for(int i = 0; i <= forPercentage*delta; i++) {
    forDisplay.setLed(0, i / 8, i % 8, true);

  for(int i = 0; i <= 25; i++) {
    againstDisplay.setLed(0, i / 8, i % 8, true);

  //Serial.println("Displaying results");

  // turn off all the leds regardless of whether they were turned on


void loop() {

  // read button states
  buttonStateFor = digitalRead(buttonForPin);
  buttonStateAgainst = digitalRead(buttonAgainstPin);

  //button pressed
  if(buttonStateFor == HIGH) {
    Serial.println("voted for");
    digitalWrite(forLedPin, HIGH);
    digitalWrite(forLedPin, LOW);
    //Serial.println("Now vote again");
  if(buttonStateAgainst == HIGH){
    Serial.println("voted against");
    digitalWrite(againstLedPin, HIGH);
    digitalWrite(againstLedPin, LOW);
    //Serial.println("Now vote again");

Some notes:
I did not import the LedControl library as a library, rather I imported it as two separate files. Everything compiles, and the buttons work and made the code go through showResults(). The calculations of the percentages is correct.
As for the electronics, I double and triple checked the connections, and they are all connected correctly. I am using 1k ohm resistors, and the capacitor. The Arduino is getting 9V, and both MAX7219s are being powered by the 5V output pin.

Any help would be greatly appreciated.

1k ohm is probably way too small - check the data sheet for the MAX7219, it likes really big resistors for Iset. Try 60k.

I'm sure the arduino 5V pin will not deliver the current 100 LED's will draw. You need to calculate the ISET resistor to match your LED's, I have a 27K resistor in my circuit to drive 64 bright white LED's

Hi, Im new here but i was looking at a PCB that I have made by Microsoft, and they drive 8x8 LED matrix's with 22K resistor for the max7219 Intergrated Circuit, thought this may help.

Also im having trouble looking for the "set up code" for driving the max7219 IC with the Arduino, could someone link it to me?


Also im having trouble looking for the "set up code" for driving the max7219 IC with the Arduino, could someone link it to me?

By far the most popular library for the MAX7219/MAX7221 is LedControl. It has several examples included in the library download.

Thanks :slight_smile: