I have an Arduino driving 6 separate MAX7219 displays. My data will display very quickly for a split second, but then disappear. Each one can be driven fine when only one is running. What is happening? More info can be provided if needed.
Code
/* matrix[3] = {data, load, clock} */
int TL[3] = {0, 1, 2};
int TM[3] = {3, 4, 5};
int TR[3] = {6, 7, 8};
int BL[3] = {A1, A2, A3};
int BM[3] = {A0, A4, A5};
int BR[3] = {9, 10, 11};
int matrixList[3][5] = {TL[3], TM[3], TR[3], BL[3], BM[3], BR[3]};
byte A[8] = {0, B11111100, B00010010, B00010001, B00010001, B00010010, B11111100, 0};
byte happy[24] = {B00000000,B11111111,B00001000,B00001000,B11111111,B00000000,B11111110,B00001001,
B11111110,B00000000,B11111110,B00001001,B00001001,B00000110,B00000000,B11111110,
B00001001,B00001001,B00000110,B00000000,B00000111,B11111000,B11111000,B00000111};
byte jess[48] = {B00000000,B00000011,B00000011,B00000011,B11111111,B00000011,B00000011,B00000000,
B11111111,B01000001,B01000001,B01000001,B01000001,B00000000,B01111110,B10000001,
B00000010,B00000100,B00000000,B00000000,B01111110,B10000001,B00000010,B00000100,
B00000000,B01110000,B10000000,B01000000,B00111111,B00000000,B00000000,B00000000,
B11111111,B10000000,B10000000,B10000000,B10000000,B00000000,B01000000,B10000000,
B01000001,B00111110,B00000000,B00000000,B01000000,B10000000,B01000001,B00111110};
byte max7219_reg_noop = 0x00;
byte max7219_reg_digit0 = 0x01;
byte max7219_reg_digit1 = 0x02;
byte max7219_reg_digit2 = 0x03;
byte max7219_reg_digit3 = 0x04;
byte max7219_reg_digit4 = 0x05;
byte max7219_reg_digit5 = 0x06;
byte max7219_reg_digit6 = 0x07;
byte max7219_reg_digit7 = 0x08;
byte max7219_reg_decodeMode = 0x09;
byte max7219_reg_intensity = 0x0a;
byte max7219_reg_scanLimit = 0x0b;
byte max7219_reg_shutdown = 0x0c;
byte max7219_reg_displayTest = 0x0f;
void putByte(int matrixNum[], byte data) {
byte i = 8;
byte mask;
while(i > 0) {
mask = 0x01 << (i - 1); // get bitmask
digitalWrite(matrixNum[2], LOW); // tick
if (data & mask){ // choose bit
digitalWrite(matrixNum[0], HIGH);// send 1
}else{
digitalWrite(matrixNum[0], LOW); // send 0
}
digitalWrite(matrixNum[2], HIGH); // tock
--i; // move to lesser bit
}
delay(10);
}
void matrixWrite(int matrix[], byte reg, byte col) {
digitalWrite(matrix[1], LOW); // begin
putByte(matrix, reg); // specify register
putByte(matrix, col);//((data & 0x01) * 256) + data >> 1); // put data
digitalWrite(matrix[1], LOW); // and load da ■■■■
digitalWrite(matrix[1],HIGH);
}
void initMatrix(int matrix[3]) {
for(int i = 0; i < 3; i++) {
pinMode(matrix[i], OUTPUT);
}
matrixWrite(matrix, max7219_reg_scanLimit, 0x07);
matrixWrite(matrix, max7219_reg_decodeMode, 0x00);
matrixWrite(matrix, max7219_reg_shutdown, 0x01);
matrixWrite(matrix, max7219_reg_displayTest, 0x00);
for (int e=1; e<=8; e++) {
matrixWrite(matrix, e,0);
}
matrixWrite(matrix, max7219_reg_intensity, 0x0f & 0x0f);
}
void clearMatrix(int matrix[]) {
for (int e = 1; e <= 8; e++) {
matrixWrite(matrix, e, 0);
}
}
void setup () {
}
void loop () {
initMatrix(TL);
matrixWrite(TL, 1, jess[0]);
matrixWrite(TL, 2, jess[1]);
matrixWrite(TL, 3, jess[2]);
matrixWrite(TL, 4, jess[3]);
matrixWrite(TL, 5, jess[4]);
matrixWrite(TL, 6, jess[5]);
matrixWrite(TL, 7, jess[6]);
matrixWrite(TL, 8, jess[7]);
initMatrix™;
matrixWrite(TM, 1, jess[8]);
matrixWrite(TM, 2, jess[9]);
matrixWrite(TM, 3, jess[10]);
matrixWrite(TM, 4, jess[11]);
matrixWrite(TM, 5, jess[12]);
matrixWrite(TM, 6, jess[13]);
matrixWrite(TM, 7, jess[14]);
matrixWrite(TM, 8, jess[15]);
initMatrix(TR);
matrixWrite(TR, 1, jess[16]);
matrixWrite(TR, 2, jess[17]);
matrixWrite(TR, 3, jess[18]);
matrixWrite(TR, 4, jess[19]);
matrixWrite(TR, 5, jess[20]);
matrixWrite(TR, 6, jess[21]);
matrixWrite(TR, 7, jess[22]);
matrixWrite(TR, 8, jess[23]);
initMatrix(BL);
matrixWrite(BL, 1, jess[24]);
matrixWrite(BL, 2, jess[25]);
matrixWrite(BL, 3, jess[26]);
matrixWrite(BL, 4, jess[27]);
matrixWrite(BL, 5, jess[28]);
matrixWrite(BL, 6, jess[29]);
matrixWrite(BL, 7, jess[30]);
matrixWrite(BL, 8, jess[31]);
initMatrix(BM);
matrixWrite(BM, 1, jess[32]);
matrixWrite(BM, 2, jess[33]);
matrixWrite(BM, 3, jess[34]);
matrixWrite(BM, 4, jess[35]);
matrixWrite(BM, 5, jess[36]);
matrixWrite(BM, 6, jess[37]);
matrixWrite(BM, 7, jess[38]);
matrixWrite(BM, 8, jess[39]);
initMatrix(BR);
matrixWrite(BR, 1, jess[40]);
matrixWrite(BR, 2, jess[41]);
matrixWrite(BR, 3, jess[42]);
matrixWrite(BR, 4, jess[43]);
matrixWrite(BR, 5, jess[44]);
matrixWrite(BR, 6, jess[45]);
matrixWrite(BR, 7, jess[46]);
matrixWrite(BR, 8, jess[47]);
while(1);
}
That’s the code. As for the schematic,I don’t have an documented one. It’s basically connected like this: The leds are connected like here: http://wiring.org.co/learning/libraries/hellomatrix.html. Each matrix has its own 3 data pins, as shown above. each matrix has its own 5V power supply.
Why didn’t you just provide the extra info in the first place?
I mean, the first response was, “Yes, please give us more info”. Then you provided the info…
Doing some simple math here, I come up with one reply wasted (that could have helped you right-off-the-bat), more time until you can get your project going, and in the end, you had to provide it anyway. Sheesh.
GIGO