Good day,
After reading and reading i just did not found a solution to my problem so i hope you can help me out.
For a project i'm trying to use 2 8x8 led matrix boards with a different animation per board. The animations are more then 20 seconds long (i will post only a part of it because its useless to post it all) so its a lot of code! (For the animation code i use this https://xantorohara.github.io site)
I'm trying to use different pins for each matrix board because for me its much easier to write that way
Both sketches work! But i don't know how to combine them so that the Arduino can play them both at the same time
first sketch
#include <LedControl.h>
const int DIN_PIN = 7;
const int CS_PIN = 9;
const int CLK_PIN = 8;
const uint64_t IMAGES[] PROGMEM = {
0x00009f9f9f9f0000,
0x007e9f9f9f9f7e00,
0x3c7e9f9f9f9f7e3c,
0x3c7e9f9f9f9f7e3c,
0x3c7e9f9f9f9f7e3c,
0x3c7e9f9f9f9f7e3c,
0x3c7e9f9f9f9f7e3c,
0x3c7e9f9f9f9f7e3c,
0x3c7e9f9f9f9f7e3c,
0x3c7e9f9f9f9f7e3c,
0x3c7e9f9f9f9f7e3c,
0x3c7e9f9f9f9f7e3c,
0x3c7e9f9f9f9f7e3c,
0x3c7e9f9f9f9f7e3c,
0x3c7e9f9f9f9f7e3c,
0x3c7e9f9f9f9f7e3c,
0x3c7e9f9f9f9f7e3c,
0x3c7e9f9f9f9f7e3c,
};
const int IMAGES_LEN = sizeof(IMAGES)/8;
LedControl display = LedControl(DIN_PIN, CLK_PIN, CS_PIN);
void setup() {
display.clearDisplay(0);
display.shutdown(0, false);
display.setIntensity(0, 10);
}
void displayImage(uint64_t image) {
for (int i = 0; i < 8; i++) {
byte row = (image >> i * 8) & 0xFF;
for (int j = 0; j < 8; j++) {
display.setLed(0, i, j, bitRead(row, j));
}
}
}
int i = 0;
void loop() {
uint64_t image;
memcpy_P(&image, &IMAGES[i], 8);
displayImage(image);
if (++i >= IMAGES_LEN ) {
i = 0;
}
delay(70);
}
second sketch
#include <LedControl.h>
const int DIN_PIN = 12;
const int CS_PIN = 10;
const int CLK_PIN = 11;
const uint64_t IMAGES[] PROGMEM = {
0x3c7ee7e7e7e77e3c,
0x3c7ee7e7e7e77e3c,
0x3c7ee7e7e7e77e3c,
0x3c7ee7e7e7e77e3c,
0x3c7ee7e7e7e77e3c,
0x3c7ee7e7e7e77e3c,
0x3c7ee7e7e7e77e3c,
0x3c7ee7e7e7e77e3c,
0x007ee7e7e7e77e00,
0x0000e7e7e7e70000,
0x000000e7e7000000,
0x0000000000000000,
0x000000e7e7000000,
0x0000e7e7e7e70000,
0x007ee7e7e7e77e00,
0x3c7ee7e7e7e77e3c,
};
const int IMAGES_LEN = sizeof(IMAGES)/8;
LedControl display = LedControl(DIN_PIN, CLK_PIN, CS_PIN);
void setup() {
display.clearDisplay(0);
display.shutdown(0, false);
display.setIntensity(0, 10);
}
void displayImage(uint64_t image) {
for (int i = 0; i < 8; i++) {
byte row = (image >> i * 8) & 0xFF;
for (int j = 0; j < 8; j++) {
display.setLed(0, i, j, bitRead(row, j));
}
}
}
int i = 0;
void loop() {
uint64_t image;
memcpy_P(&image, &IMAGES[i], 8);
displayImage(image);
if (++i >= IMAGES_LEN ) {
i = 0;
}
delay(70);
}