I have a little problem using 12pcs of MAX7219, I can't run more then 2 max7219. I use code:
#include "LedControl.h" // need the library
LedControl lc=LedControl(12,11,10,12); //
// 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()
{
lc.shutdown(0,false);// turn off power saving, enables display
lc.setIntensity(0,15);// sets brightness (0~15 possible values)
lc.clearDisplay(0);// clear screen
lc.shutdown(1,false);// turn off power saving, enables display
lc.setIntensity(1,8);// sets brightness (0~15 possible values)
lc.clearDisplay(1);// clear screen
}
void loop()
{
lc.setLed(2,0,1,true);
delay(50);
//lc.setLed(2,0,1,false);
//delay(50);
}
If I run only max number 1 it is ok
If I run only max number 2 it is ok
If I run only max number 3 it is ok
If I run max number 1 and 2 it is ok
If I run max number 1 and 3 it is ok
If I run max number 2 and 3 it is ok
If I run max number 1, 2 and 3 then number 3 not work
as i see only 8 devices are allowed for one LedControl variable.
LedControl lc=LedControl(12,11,10,12);
and you assigned 12 to it.
The fourth argument to LedControl(dataPin,clockPin,csPin,numDevices) is the number of cascaded MAX72XX devices you're using with this LedControl. The library can address up to 8 devices from a single LedControl-variable. There is a little performance penalty implied with each device you add to the chain, but amount of memory used by the library-code will stay the same, no matter how many devices you set. Since one LedControl cannot address more than 8 devices, only values between 1..8 are allowed here.
but in the end your free to do what you want so when the library only allaws 8 MAX7219. (i dont know everything about this library)
you need to find a otherway to do it. but as i see on the manual from MAX7219 it should be possible to daisy chain them endless.
There is no limit in the MAX7219 hardware on how many you can cascade, as long as you provide enough power and properly condition the control and data signals. 12 devices are easily achievable and I have seen as many as 24 chained.
Ledcontrol imposes the limit on the number of devices in the library. I don't know why, but when I have tried using it in the past, it seemed to be relatively slow when many devices are connected (so maybe this was a compromise from the writer of the library).
You can change the limit in the library and test for your own application. You will need to edit the constants defined in the library to do this.
Alternatively you can try other libraries that do not impose these limits, but they work differently from Ledcontrol so your code will need to change. One such library is the MD_MAX72xx library that you can download from the links in my signature below. If you use this library, please make sure that you read the documentation and set up the library for your hardware configuration/LED module wiring.