#include <MD_MAX72xx.h>
#define MAX_DEVICES 2
const int maxX = 8;
const int maxY = 16;
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
#define VERT_PIN A0
#define HORZ_PIN A1
#define SEL_PIN 2
MD_MAX72XX mx = MD_MAX72XX(MD_MAX72XX::PAROLA_HW, CS_PIN, MAX_DEVICES);
void setup() {
mx.begin();
mx.control(MD_MAX72XX::INTENSITY, MAX_INTENSITY / 2);
mx.clear();
pinMode(VERT_PIN, INPUT);
pinMode(HORZ_PIN, INPUT);
pinMode(SEL_PIN, INPUT_PULLUP);
}
const int width = 8;
const int height = 8;
// 8x8 bitmap für den Buchstaben A
int bitmapA[height][width] = {
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 1, 0, 0, 1, 0, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0}
};
// 8x8 bitmap für den Buchstaben B
int bitmapB[height][width] = {
{0, 1, 1, 1, 1, 0, 0, 0},
{0, 1, 0, 0, 1, 1, 0, 0},
{0, 1, 0, 0, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 0, 0, 0},
{0, 1, 0, 0, 0, 1, 0, 0},
{0, 1, 0, 0, 0, 1, 0, 0},
{0, 1, 0, 0, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 0, 0, 0}
};
// 8x8 bitmap für den Buchstaben C
int bitmapC[height][width] = {
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 0, 0, 1, 1, 0},
{1, 0, 0, 0, 0, 0, 1, 0},
{1, 0, 0, 0, 0, 0, 0, 0},
{1, 0, 0, 0, 0, 0, 0, 0},
{1, 0, 0, 0, 0, 0, 1, 0},
{0, 1, 1, 0, 0, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 0, 0}
};
// 8x8 bitmap für herzi
int bitmap3[height][width] = {
{0, 1, 0, 0, 0, 0, 1, 0},
{1, 0, 1, 0, 0, 1, 0, 1},
{1, 0, 0, 1, 1, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 1},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 0, 1, 0, 0, 1, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}
};
// 8x8 bitmap für den Buchstaben H
int bitmapH[height][width] = {
{0, 1, 1, 0, 0, 1, 1, 0},
{0, 1, 1, 0, 0, 1, 1, 0},
{0, 1, 1, 0, 0, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 0, 0, 1, 1, 0},
{0, 1, 1, 0, 0, 1, 1, 0},
{0, 1, 1, 0, 0, 1, 1, 0}
};
// 8x8 bitmap für den Buchstaben E
int bitmapE[height][width] = {
{0, 1, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 0, 0}
};
void drawLetter(int sx, int sy, int status, int theBitmap[8][8]) {
// Anzeigen des Buchstaben
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
if (theBitmap[y][x]) {
mx.setPoint(sx + y, sy + 7 - x, status);
}
}
}
}
void drawSquare(int sx, int sy, int status) {
for (int ox = 0; ox <= 3; ox = ox + 1 ) {
for (int oy = 0; oy <= 3; oy = oy + 1) {
mx.setPoint(sx + ox, sy + oy, status);
}
}
mx.update();
}
int x = 0;
int y = 0;
int status = 1;
// the loop function runs over and over again forever
void loop() {
if (digitalRead(SEL_PIN) == LOW) {
mx.clear();
}
x = 0;
y = 0;
drawLetter(x, y, 1, bitmapE);
mx.update();
drawLetter(x, y + 8, 1, bitmapH);
mx.update();
drawLetter(x, y + 16, 1, bitmap3);
mx.update();
drawLetter(x, y + 24, 1, bitmap3);
mx.update();
delay(500);
// drawSquare(x,y,0);
drawLetter(x, y, 0, bitmap3);
y = y + 1 ;
}