The problem is you're reading outside the bounds of screen
. Screen has valid addresses of 0-7, and you're trying to read from screen[8][n]
.
8
887|22021|-15872|-30720|124|2|9|10
^ How can you have line "8"? The line number is Serial.println(i-1);
, and the value is Serial.print(screen[i-1][0]);
, so the error will be present in the array access as well. To fix it, you just need to change to screen[i-2]
.
Ok, the other corruption (6
0|0|0|0|0|0|Á
) issue is because you're heavily oversaturating the serial port. I stuck a 1 second delay in after each loop, and it fixed that issue.
Change:
void loop() {
static int display [8][8] = {
{1,0,0,0,0,0,0,0},
{0,1,0,0,0,0,0,0},
{0,0,1,0,0,0,0,0},
{0,0,0,1,0,0,0,0},
{0,0,0,0,1,0,0,0},
{0,0,0,0,0,1,0,0},
{0,0,0,0,0,0,1,0},
{0,0,0,0,0,0,0,1}
};
updateScreen(display);
delay(1000); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
or
void updateScreen(int screen[8][8]) {
Serial.begin(115200);
int i;
<snip>
Output:
0
1|0|0|0|0|0|0|0
1
0|1|0|0|0|0|0|0
2
0|0|1|0|0|0|0|0
3
0|0|0|1|0|0|0|0
4
0|0|0|0|1|0|0|0
5
0|0|0|0|0|1|0|0
6
0|0|0|0|0|0|1|0
7
0|0|0|0|0|0|0|1
I also tried simply increasing the baud-rate (to 115200
baud), and that also fixed the issue without the delay, so either option would work.
Best Answer
Bryan Chung had a tutorial still available on the Internet Archive on how to connect a LED Matrix to an Arduino using a MAX7219: