Hello,
I'm new to Arduino and currently working with an Arduino Nano powered by an external power supply. I'm experimenting with LED matrices — I've connected 10 of them in series and I'm trying to display numbers from 0 to 9.
The first 8 numbers display correctly, but for some reason, the last two matrices don't show 8 and 9. Instead, they repeat 0 and 1. I've also tried displaying different symbols, but the result is always the same — the last two matrices show the first two symbols again.
I would really appreciate any advice or suggestions.
Thanks!
My code:
#include "LedControl.h"
#define DIN 10
#define CS 11
#define CLK 12
#define matrix 10
#define bright 5
LedControl ledMat=LedControl(DIN, CLK, CS, matrix);
byte num0[8] = {
B00000000,
B00011000,
B00100100,
B01000010,
B01000010,
B00100100,
B00011000,
B00000000
};
byte num1[8] = {
B00000000,
B00010000,
B00110000,
B00010000,
B00010000,
B00010000,
B00111000,
B00000000
};
byte num2[8] = {
B00000000,
B00111000,
B01000100,
B00000100,
B00011000,
B00100000,
B01111100,
B00000000
};
byte num3[8] = {
B00000000,
B00111000,
B01000100,
B00001000,
B00000100,
B01000100,
B00111000,
B00000000
};
byte num4[8] = {
B00000000,
B00001000,
B00011000,
B00101000,
B01001000,
B01111100,
B00001000,
B00000000
};
byte num5[8] = {
B00000000,
B01111100,
B01000000,
B01111000,
B00000100,
B01000100,
B00111000,
B00000000
};
byte num6[8] = {
B00000000,
B00111000,
B01000000,
B01111000,
B01000100,
B01000100,
B00111000,
B00000000
};
byte num7[8] = {
B00000000,
B01111100,
B00000100,
B00001000,
B00010000,
B00010000,
B00010000,
B00000000
};
byte num8[8] = {
B00000000,
B00111000,
B01000100,
B00111000,
B01000100,
B01000100,
B00111000,
B00000000
};
byte num9[8] = {
B00000000,
B00111000,
B01000100,
B01000100,
B00111100,
B00000100,
B00111000,
B00000000
};
void setup() {
for(int j=0; j<matrix; j++) {
ledMat.shutdown(j,false);
ledMat.setIntensity(j,bright);
ledMat.clearDisplay(j);
}
}
void loop() {
for(int i=0; i<8; i++) {
ledMat.setRow(0, i, num0[i]);
ledMat.setRow(1, i, num1[i]);
ledMat.setRow(2, i, num2[i]);
ledMat.setRow(3, i, num3[i]);
ledMat.setRow(4, i, num4[i]);
ledMat.setRow(5, i, num5[i]);
ledMat.setRow(6, i, num6[i]);
ledMat.setRow(7, i, num7[i]);
ledMat.setRow(8, i, num8[i]);
ledMat.setRow(9, i, num9[i]);
}
}


