Pages: [1]   Go Down
Author Topic: [SOLVED] Need help with Max7219 and LedControl library  (Read 1386 times)
0 Members and 1 Guest are viewing this topic.
Seminole
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm trying to hook up my Arduino Uno to a Max7219 led controller and 1 Seven segment LED Display.  At this point I'm just trying to connect to only 1 display to keep things simple.  I've used the following wiring schematics as my guide:

http://playground.arduino.cc/Main/MAX72XXHardware and
http://tronixstuff.wordpress.com/2010/07/09/review-maxim-max7219-led-display-driver-ic/

I'm new to electronics.  I've downloaded the LedControl library and I've only coded the bare minimum programming to see if I can test my wiring. I didn't even code the Loop() event, only the Setup(). I've included some pictures to show you how it's wired up.  I've also included the program at the bottom.  

I was successful in getting the display to show the number 1 and the number 7.  I can't get any other numbers to display.  What happens is when the program starts, the number I'm trying to display flashes for a split second then vanishes.  I've included a video of this below.  I'm not even sure what the arguments to setDigit are - I was guessing and was lucky so far.  I can't find any documentation for the functions in the LedControl library - I can only find articles where people tend to get overly complicated.  

1 - I was hoping someone could offer assistance with the setDigit function.  I'm trying to display a number on a single LED display as shown below. Nothing fancy.  Am I using the function incorrectly below?
2- Why do you think only 1 and 7 works but other numbers don't.  I thought it had to do with the fact that numbers 1 and 7 use the least amount of led segments (2 and 3 segments).  I thought maybe my USB port was not supplying enough juice.  So I hooked up a power supply to the Arduino and it still behaved the same way.
3- When I wired the LED I connected the bottom common cathode pin to the Max7219 Dig0 pin (pin 2). I left the other CC unconnected as it appeared that way in the article referenced above. I also tried connecting this to the Arduino ground.   No difference.
Thank you very much for any assistance offered!  

Here are some pictures of my setup












The next pics show the numbers 1 and 7 lighting up ok.




Here's a video of the quick flash problem: http://youtu.be/24TWoQGE0xM

Here's the code I'm running:

Code:
#include "LedControl.h" //  need the library
LedControl lc=LedControl(12,11,10,1); // lc is our object
// pin 12 is connected to the MAX7219 pin 1
// pin 11 is connected to the CLK pin 13
// pin 10 is connected to LOAD pin 12
// 1 as we are only using 1 MAX7219
void setup()
{
  // the zero refers to the MAX7219 number, it is zero for 1 chip
  lc.shutdown(0,false);// turn off power saving, enables display
  lc.setIntensity(0,8);// sets brightness (0~15 possible values)
  lc.clearDisplay(0);// clear screen
  lc.setDigit(0,0,2,false);  //This does not work. Only 1 and 7 does
}
void loop()
{
    //This code successfully flashes 1 and 7 but I've
    //commented this out for now.
    //lc.setDigit(0,0,0,false);
    //delay(1000);
    //lc.setDigit(0,0,7,false);
    //delay(1000);
}

Thanks again!
« Last Edit: February 01, 2013, 09:01:29 pm by largomike1 » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's my attempt:

http://www.gammon.com.au/forum/?id=11516

I used 27K for the ISET resistor. 1K may be too low.
Logged

0
Offline Offline
God Member
*****
Karma: 2
Posts: 854
Arduino rocks!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I used 27K for the ISET resistor. 1K may be too low.

My guess is this is the problem.  The datasheet says it should be at least 9.53k which sets the current at 40mA.  The current drivers are set at 100 times the current through this resistor and 40mA is the limit for the device.   

1 and 7 only use 2-3 segments, any other digit uses more, so it does explain your symtoms too.
Logged

Seminole
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the reply.  This was my first attempt and I wasn't sure about the resistor.  I'm going to try that tonight.  I'll update this post with my results. Thanks again!
Logged

Seminole
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well that worked!   smiley-surprise I was able to get a 33k Ohm resistor at Radio Shack.  That did the trick.  Now I'm going to try and add more digits, with the hope of testing 8 digits.  Thanks again. 
Logged

Seminole
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just had to update this.  I was able to add another digit and create a little routine that counts down from 99 to 0 and repeats the cycle.  Now that I've done 2 digits, I should hopefully be able to complete the remaining 6.  Here's a video link and the code.

By the way - the LedControl library makes this so much easier.

Quick video:

http://youtu.be/eldgeiYAxII

The code:
Code:
#include "LedControl.h" //  need the library
LedControl lc=LedControl(12,11,10,1); // lc is our object
// pin 12 is connected to the MAX7219 pin 1
// pin 11 is connected to the CLK pin 13
// pin 10 is connected to LOAD pin 12
// 1 as we are only using 1 MAX7219
void setup()
{
  // the zero refers to the MAX7219 number, it is zero for 1 chip
  lc.shutdown(0,false);// turn off power saving, enables display
  lc.setIntensity(0,8);// sets brightness (0~15 possible values)
  lc.clearDisplay(0);// clear screen
 
}


void loop()
{
    //This code should count down from 99 displaying the numbers on the two digits
    static int theNumber = 99;
    int digitOne, digitTwo;
   
    if (theNumber < 0)
      theNumber = 99;
     
    if (theNumber > 9)
    {
      float result = theNumber / 10;  //s/b 4.2 resulting in 4
      digitOne = result;
      digitTwo = theNumber % 10;  //this gets the remainder of 42/10 or 2
    }
    else
    {
      digitOne = 0;
      digitTwo = theNumber; 
    }

    lc.setDigit(0,0,digitOne,false); 
    lc.setDigit(0,1,digitTwo,false);
    delay(100);
    theNumber --;
   
}
Logged

Dee Why NSW
Offline Offline
Edison Member
*
Karma: 30
Posts: 1670
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for that, I have done something useful with the 4x7 for the first time.
I found I had to make a minor change in the loop in order to get the number display the right way round
Code:
void loop()
{
    if (theNumber < 0)
      theNumber = 99;
     
    if (theNumber > 9)
    {
      float result = theNumber / 10;  //s/b 4.2 resulting in 4
      digitTwo = result;
      digitOne = theNumber % 10;  //this gets the remainder of 42/10 or 2
    }
    else
    {
      digitTwo = 0;
      digitOne = theNumber; 
    }
    lc.setDigit(0,0,digitOne,false); 
    lc.setDigit(0,1,digitTwo,false);
    delay(1000);
    theNumber --;//count down!!
}
Logged

Pages: [1]   Go Up
Jump to: