Why 500? 512 each side would be even... (0 - 511), (512 - 1023)
I think the first value (0) is the panel number... so the second panel will be (1).
This is how to set/reset one LED in a panel...
lc.setLed(0, 0, 0, state); // panel 0, x = 0, y = 0, ON/OFF
Connecting the panels...
VCC - VCC
GND - GND
DOUT - DIN (data moving left to right)
CS - CS
CLK - CLK
I see how moving the potentiometer on A0 "lowers" and "raises" the LEDs... what is the pattern you want reflected on panel 1?
I think this might be what you had in mind... I added comments...
#include <LedControl.h>
int DIN = 11;
int CS = 10;
int CLK = 13;
LedControl lc = LedControl(DIN, CLK, CS, 2);
void setup() {
Serial.begin(115200);
lc.shutdown(0, false);
lc.setIntensity(0, 50);
lc.clearDisplay(0);
}
void printByte(byte character [], int panel) {
int i = 0;
for (i = 0; i < 8; i++) {
lc.setRow(panel, i, character[i]);
}
}
void loop() {
int panel; // which panel to use
byte cero[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
int value = analogRead(A0); // read of potentiometer value
int scale = map(value, 0, 1023, 0, 17); // 16 rows, plus one
if (value > 512) { // if raw potentiometer is above middle, use panel 0, subtract 8 for row
panel = 0;
scale = scale - 8;
} else { // if raw potentiometer is below middle, use panel 1, subtract row from 8
panel = 1;
scale = 8 - scale;
}
for (int i = 0; i < scale; i++) {
cero[i] = 0xff;
}
printByte(cero, panel);
// delay(100);
}
Put this file in WOKWI.COM diagram.json tab
{
"version": 1,
"author": "Anonymous maker",
"editor": "wokwi",
"parts": [
{ "type": "wokwi-arduino-nano", "id": "nano", "top": 4.8, "left": -86.9, "attrs": {} },
{
"type": "wokwi-max7219-matrix",
"id": "matrix1",
"top": -143.4,
"left": -110.18,
"attrs": { "chain": "2" }
},
{ "type": "wokwi-potentiometer", "id": "pot1", "top": -10.9, "left": 134.2, "attrs": {} }
],
"connections": [
[ "nano:11", "matrix1:DIN", "green", [ "v-57.6", "h163.2", "v-38.4" ] ],
[ "nano:10", "matrix1:CS", "green", [ "v-48", "h144", "v-38.4" ] ],
[ "nano:13", "matrix1:CLK", "green", [ "v-96", "h153.6", "v-38.4" ] ],
[ "matrix1:GND", "nano:GND.2", "black", [ "h38.4", "v96", "h-76.8" ] ],
[ "nano:5V", "matrix1:V+", "red", [ "v19.2", "h86.4", "v-211.2" ] ],
[ "pot1:GND", "nano:GND.1", "black", [ "v19.2", "h-105.6" ] ],
[ "pot1:VCC", "nano:5V", "red", [ "v28.8", "h-144.8" ] ],
[ "nano:A0", "pot1:SIG", "green", [ "v28.8", "h201.6" ] ]
],
"dependencies": {}
}