#include <LedControl.h>
#define DATA_IN 2
#define CLK 3
#define CS 4
LedControl lc = LedControl(DATA_IN, CLK, CS, 4); // Menggunakan 4 modul 8x8
// Emotikon - dalam bentuk array 8x32
byte emoticon1[8] = {
B00111100,
B01000010,
B10100101,
B10000001,
B10100101,
B10011001,
B01000010,
B00111100
};
byte emoticon2[8] = {
B00000000,
B01100110,
B11111111,
B11111111,
B01111110,
B00111100,
B00011000,
B00000000
};
byte emoticon3[8] = {
B00111100,
B01000010,
B10100101,
B10000001,
B10011001,
B10100101,
B01000010,
B00111100
};
void setup() {
// Inisialisasi modul MAX7219
for (int i = 0; i < 4; i++) {
lc.shutdown(i, false); // Nonaktifkan mode sleep
lc.setIntensity(i, 8); // Atur kecerahan LED (0-15)
lc.clearDisplay(i); // Hapus tampilan sebelumnya
}
}
void displayEmoticon(byte emoticon[]) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 4; j++) {
lc.setRow(j, i, emoticon[i]);
}
}
}
void loop() {
// Tampilkan emotikon 1
displayEmoticon(emoticon1);
delay(1000);
for (int i = 0; i < 4; i++) {
lc.clearDisplay(i);
}
delay(500);
// Tampilkan emotikon 2
displayEmoticon(emoticon2);
delay(1000);
for (int i = 0; i < 4; i++) {
lc.clearDisplay(i);
}
delay(500);
// Tampilkan emotikon 3
displayEmoticon(emoticon3);
delay(1000);
for (int i = 0; i < 4; i++) {
lc.clearDisplay(i);
}
delay(500);
}