#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
// #define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
// #define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4 // Jumlah modul dot matrix
// Pin untuk MAX7219
#define DATA_PIN 11
#define CLK_PIN 13
#define CS_PIN 10
int buttonPin= A0;
int tombol =0;
int tekan_ke=0;
int LED1=2;
int LED2=3;
int LED3=4;
int LED4=5;
// Inisialisasi library Parola
MD_Parola P1 = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
MD_Parola P2 = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
void setup() {
// Inisialisasi Parola
P1.begin();
P1.setIntensity(5); // Atur kecerahan (0-15)
P1.displayClear();
P2.begin();
P2.setIntensity(5); // Atur kecerahan (0-15)
P2.displayClear();
pinMode(buttonPin, INPUT_PULLUP);
pinMode(LED1, OUTPUT);
}
void loop() {
// Tampilkan teks bergerak dari kanan ke kiri
if(digitalRead(buttonPin)==LOW){
tekan_ke++;
delay(500);
}
if(tekan_ke==1){
// PA_SCROLL_LEFT: Teks bergerak ke kiri
// PA_SCROLL_UP Teks bergerak ke atas
digitalWrite(LED1, HIGH);
digitalWrite(LED2, HIGH);
digitalWrite(LED3, LOW);
digitalWrite(LED4, LOW);
}
if(tekan_ke==2){
if (P1.displayAnimate()) { // Periksa apakah animasi selesai
P1.displayText("RICKY 124650198", PA_CENTER, 100, 200, PA_SCROLL_LEFT, PA_SCROLL_UP);
digitalWrite(LED1, LOW);
digitalWrite(LED2, LOW);
digitalWrite(LED3, LOW);
digitalWrite(LED4, LOW);
}
}
if(tekan_ke==3){
digitalWrite(LED1, LOW);
digitalWrite(LED2, LOW);
digitalWrite(LED3, HIGH);
digitalWrite(LED4, HIGH);
P1.displayClear();
tekan_ke=0;
}
}