#include <GyverMAX7219.h>
#define CS_PIN (12)
#define X_SIZE (1)
#define Y_SIZE (1)
#define BRIGHT (5)
#define NUM (10)
MAX7219<X_SIZE, Y_SIZE, CS_PIN> mtrx;
const uint8_t equality_B[] PROGMEM = {0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00};
void setup()
{
mtrx.begin();
mtrx.setBright(BRIGHT);
mtrx.dot(0, 0);
mtrx.update();
delay(1000);
mtrx.clear();
mtrx.setRotation(1);
mtrx.dot(0, 0);
mtrx.update();
delay(1000);
mtrx.clear();
mtrx.setRotation(2);
mtrx.dot(0, 0);
mtrx.update();
delay(1000);
mtrx.clear();
mtrx.setRotation(3);
mtrx.dot(0, 0);
mtrx.update();
delay(1000);
mtrx.clear();
mtrx.setRotation(0);
mtrx.line(0, 0, 7, 7);
mtrx.line(7, 0, 0, 7);
mtrx.update();
delay(1000);
mtrx.clear();
mtrx.drawBitmap(0, 0, equality_B, 8, 8);
mtrx.update();
delay(1000);
mtrx.clear();
mtrx.setFlip(false, true);
mtrx.setCursor(0, 7);
mtrx.update();
delay(1000);
}
const uint8_t animation_1_01[] PROGMEM = {0x00, 0x66, 0x99, 0x81, 0x42, 0x24, 0x18, 0x00};
const uint8_t animation_1_02[] PROGMEM = {0x00, 0x00, 0x66, 0x7e, 0x3c, 0x18, 0x00, 0x00};
const uint8_t animation_1_03[] PROGMEM = {0x00, 0x66, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00};
const uint8_t animation_2_01[] PROGMEM = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10};
const uint8_t animation_2_02[] PROGMEM = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00};
const uint8_t animation_2_03[] PROGMEM = {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00};
const uint8_t animation_2_04[] PROGMEM = {0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00};
const uint8_t animation_2_05[] PROGMEM = {0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00};
const uint8_t animation_2_06[] PROGMEM = {0x00, 0x00, 0x28, 0x00, 0x28, 0x00, 0x00, 0x00};
const uint8_t animation_2_07[] PROGMEM = {0x00, 0x44, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00};
const uint8_t animation_2_08[] PROGMEM = {0xaa, 0x44, 0xaa, 0x00, 0xaa, 0x44, 0xaa, 0x00};
const uint8_t animation_2_09[] PROGMEM = {0x00, 0x44, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00};
const uint8_t animation_2_10[] PROGMEM = {0xaa, 0x44, 0xaa, 0x00, 0xaa, 0x44, 0xaa, 0x00};
const uint8_t animation_2_11[] PROGMEM = {0xaa, 0x00, 0xaa, 0x00, 0xaa, 0x00, 0xaa, 0x00};
const uint8_t animation_2_12[] PROGMEM = {0xaa, 0x44, 0xaa, 0x00, 0xaa, 0x44, 0xaa, 0x00};
const uint8_t animation_2_13[] PROGMEM = {0xee, 0xaa, 0xee, 0x00, 0xee, 0xaa, 0xee, 0x00};
void loop()
{
int X = (int)random(0, 2), Y = (int)random(0, 8), last = -1;
for (int i = 0; i < NUM; i++)
{
mtrx.drawBitmap(0, 0, animation_1_01, 8, 8);
mtrx.update();
delay(1000);
mtrx.clear();
mtrx.drawBitmap(0, 0, animation_1_02, 8, 8);
mtrx.update();
delay(100);
mtrx.clear();
mtrx.drawBitmap(0, 0, animation_1_03, 8, 8);
mtrx.update();
delay(500);
mtrx.clear();
mtrx.drawBitmap(0, 0, animation_1_02, 8, 8);
mtrx.update();
delay(100);
mtrx.clear();
}
mtrx.update();
delay(500);
for (int i = 0; i < NUM; i++)
{
while (X == last)
X = (int)random(0, 2);
last = X;
mtrx.drawBitmap(X, 0, animation_2_01, 8, 8);
mtrx.update();
delay(500);
mtrx.clear();
mtrx.drawBitmap(X, 0, animation_2_02, 8, 8);
mtrx.update();
delay(500);
mtrx.clear();
mtrx.drawBitmap(X, 0, animation_2_03, 8, 8);
mtrx.update();
delay(500);
mtrx.clear();
mtrx.drawBitmap(X, 0, animation_2_04, 8, 8);
mtrx.update();
delay(500);
mtrx.clear();
mtrx.drawBitmap(X, 0, animation_2_05, 8, 8);
mtrx.update();
delay(500);
mtrx.clear();
mtrx.drawBitmap(X, 0, animation_2_06, 8, 8);
mtrx.update();
delay(500);
mtrx.clear();
mtrx.drawBitmap(X, 0, animation_2_07, 8, 8);
mtrx.update();
delay(500);
mtrx.clear();
mtrx.drawBitmap(X, 0, animation_2_08, 8, 8);
mtrx.update();
delay(500);
mtrx.clear();
mtrx.drawBitmap(X, 0, animation_2_09, 8, 8);
mtrx.update();
delay(500);
mtrx.clear();
mtrx.drawBitmap(X, 0, animation_2_10, 8, 8);
mtrx.update();
delay(500);
mtrx.clear();
mtrx.drawBitmap(X, 0, animation_2_11, 8, 8);
mtrx.update();
delay(500);
mtrx.clear();
mtrx.drawBitmap(X, 0, animation_2_12, 8, 8);
mtrx.update();
delay(500);
mtrx.clear();
mtrx.drawBitmap(X, 0, animation_2_13, 8, 8);
mtrx.update();
delay(500);
mtrx.clear();
}
mtrx.update();
delay(500);
while (true)
{
do
{
last = (int)random(-1, 2);
last = X + last;
} while (last < 0 || last > 7);
X = last;
do
{
last = (int)random(-1, 2);
last = Y + last;
} while (last < 0 || last > 7);
Y = last;
mtrx.dot(X, Y);
mtrx.update();
delay(100);
mtrx.clear();
}
}