//Umi Salma Zubaidah
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 8 // max lcd
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN1 10 // layar atas
#define CS_PIN2 9 // layar bawah
#define BUZZER_PIN 8// pin untuk buzzer
#define LED_PIN 12 // pin untuk lampu
MD_Parola layar1 = MD_Parola(HARDWARE_TYPE, CS_PIN1, MAX_DEVICES);
MD_Parola layar2 = MD_Parola(HARDWARE_TYPE, CS_PIN2, MAX_DEVICES);
void setup()
{
pinMode(LED_PIN, OUTPUT);
pinMode(BUZZER_PIN, OUTPUT);
layar1.begin();
layar2.begin();
layar1.setIntensity(15); // Atur intensitas
layar2.setIntensity(15); // Atur intensitas
//layar1.displayClear();
//layar2.displayClear();
//layar1.displayText("HATI-HATI", PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
layar2.displayText("TENGOK KANAN KIRI", PA_LEFT, 0, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
}
void loop()
{
hatihati();
//tengok();
}
void hatihati()
{
digitalWrite(LED_PIN, HIGH);
delay(600);
digitalWrite(LED_PIN, LOW);
delay(250);
noTone(BUZZER_PIN);
tone(BUZZER_PIN, 600);
delay(300);
layar1.displayAnimate();
layar1.displayText("HATI-HATI", PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
tengok();
delay(1000);
tengok();
layar1.displayClear();
delay(100);
}
void tengok()
{
noTone(BUZZER_PIN);
tone(BUZZER_PIN, 500);
if (layar2.displayAnimate())
{
layar2.displayReset(); // Reset jika text habis
}
}