#include <LedControl.h>
// Pin koneksi MAX7219
#define DIN_PIN 50
#define CLK_PIN 52
#define CS_PIN 53
// Jumlah modul MAX7219
#define NUM_DEVICES 4
LedControl lc = LedControl(DIN_PIN, CLK_PIN, CS_PIN, NUM_DEVICES);
void setup() {
// Inisialisasi semua modul MAX7219
for (int i = 0; i < NUM_DEVICES; i++) {
lc.shutdown(i, false); // Hidupkan modul
lc.setIntensity(i, 5); // Atur kecerahan (0-15)
lc.clearDisplay(i); // Bersihkan layar
}
}
void loop() {
drawEyes();
delay(1000); // Tahan mata selama 1 detik
blinkEyes();
delay(500); // Kedip selama 0.5 detik
}
void drawEyes() {
// Mata kiri
lc.setLed(0, 1, 2, true); // Aktifkan titik (device, row, col)
lc.setLed(0, 2, 3, true);
lc.setLed(0, 3, 2, true);
lc.setLed(0, 2, 1, true);
// Mata kanan
lc.setLed(2, 1, 2, true); // Device ke-2
lc.setLed(2, 2, 3, true);
lc.setLed(2, 3, 2, true);
lc.setLed(2, 2, 1, true);
}
void blinkEyes() {
// Mata berkedip (garis horizontal)
lc.setLed(0, 2, 2, true);
lc.setLed(0, 2, 3, true);
lc.setLed(2, 2, 2, true);
lc.setLed(2, 2, 3, true);
}