I'm using the LedControl to control the 7-segment LEDs I'm using. I had successfully created a project with 1x MAX7219 running a 2-digit 7-seg LED and a 4-digit 7-segment LED. I then added a second MAX7219 running a 4-digit 7-segment LED.
The 2-digit LED is using Dig0 and Dig1 and the 4-digit LED on the same MAX is using Dig2, Dig3, Dig5, and Dig5. The second 4-digit LED on the second MAX is connected to Dig0, Dig1, Dig2, and Dig3. I've obviously connected all the diodes up correctly. The second MAX is connected to the first MAX from pin24 on the first to pin1 on the second.
In the code I have:
#include <LedControl.h>
const int DIN_PIN = 12;
const int CLK_PIN = 11;
const int CS_PIN = 10;
LedControl lc1 = LedControl(DIN_PIN, CLK_PIN, CS_PIN, 2);
void setup()
{
Serial.begin(9600);
Serial.print("Number of devices: ");
Serial.println(lc1.getDeviceCount());
for (int n = 0; n < lc1.getDeviceCount(); ++n)
{
/*
The MAX72XX is in power-saving mode on startup,
we have to do a wakeup call
*/
lc1.shutdown(n, false);
/* Set the brightness to a medium values */
lc1.setIntensity(n, 10);
if (n == 0)
lc1.setScanLimit(n, 6);
else
lc1.setScanLimit(n, 4);
/* and clear the display */
lc1.clearDisplay(n);
}
}
and then the programs loop to count up from 0 to 999999. The 2-digit and 4-digit work fine but the second 4-digit LED just stays with 8888. Any suggestions? I've triple checked all the wires, which are all connected correctly:
void loop()
{
for (long n = 1; n < 999999; ++n)
{
printNumber(n);
delay(1000);
}
}
void printNumber(long num)
{
long ones;
long tens;
long hundreds;
long thousands;
long m;
long n;
ones = num % 10;
num = num / 10;
tens = num % 10;
num= num / 10;
hundreds = num % 10;
num = num / 10;
thousands = num %10;
num = num / 10;
m = num % 10;
num = num / 10;
n = num;
//Now print the number digit by digit
lc1.setDigit(0, 0, (byte)n, false);
lc1.setDigit(0, 1, (byte)m, false);
lc1.setDigit(0, 2, (byte)thousands, false);
lc1.setDigit(0, 3, (byte)hundreds, false);
lc1.setDigit(0, 4, (byte)tens, false);
lc1.setDigit(0, 5, (byte)ones, false);
lc1.setDigit(1, 0, (byte)thousands, false);
lc1.setDigit(1, 1, (byte)hundreds, false);
lc1.setDigit(1, 2, (byte)tens, false);
lc1.setDigit(1, 3, (byte)ones, false);
}