#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
// Uncomment according to your hardware type
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
//#define HARDWARE_TYPE MD_MAX72XX::GENERIC_HW
// Defining size, and output pins
#define MAX_DEVICES 8
#define CS_PIN 5
#define BTN_PIN1 13
#define BTN_PIN2 12
#define MAX_FRAMES 4
MD_Parola Display = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
//const float GAMMA = 0.7;
//const float RL10 = 50;
const uint8_t pacman[MAX_FRAMES][18] = // ghost pursued by a pacman
{
{ 0xfe, 0x73, 0xfb, 0x7f, 0xf3, 0x7b, 0xfe, 0x00, 0x00, 0x00, 0x3c, 0x7e, 0x7e, 0xff, 0xe7, 0xc3, 0x81, 0x00 },
{ 0xfe, 0x7b, 0xf3, 0x7f, 0xfb, 0x73, 0xfe, 0x00, 0x00, 0x00, 0x3c, 0x7e, 0xff, 0xff, 0xe7, 0xe7, 0x42, 0x00 },
{ 0xfe, 0x73, 0xfb, 0x7f, 0xf3, 0x7b, 0xfe, 0x00, 0x00, 0x00, 0x3c, 0x7e, 0xff, 0xff, 0xff, 0xe7, 0x66, 0x24 },
{ 0xfe, 0x7b, 0xf3, 0x7f, 0xf3, 0x7b, 0xfe, 0x00, 0x00, 0x00, 0x3c, 0x7e, 0xff, 0xff, 0xff, 0xff, 0x7e, 0x3c },
};
uint8_t inFX, outFX;
textEffect_t effect[] =
{
PA_PRINT,
PA_SCAN_HORIZ,
PA_SCROLL_LEFT,
PA_WIPE,
PA_SCROLL_UP_LEFT,
PA_SCROLL_UP,
PA_OPENING_CURSOR,
PA_GROW_UP,
PA_MESH,
PA_SCROLL_UP_RIGHT,
PA_BLINDS,
PA_CLOSING,
PA_RANDOM,
PA_GROW_DOWN,
PA_SCAN_VERT,
PA_SCROLL_DOWN_LEFT,
PA_WIPE_CURSOR,
// PA_DISSOLVE,
PA_OPENING,
PA_CLOSING_CURSOR,
PA_SCROLL_DOWN_RIGHT,
PA_SCROLL_RIGHT,
//PA_SLICE,
PA_SCROLL_DOWN,
};
void setup() {
pinMode(BTN_PIN1, INPUT);
pinMode(BTN_PIN2, INPUT);
// Intialize the object:
Display.begin();
// Set the intensity (brightness) of the display (0-15):
Display.setIntensity(0);
// Clear the display:
Display.displayClear();
Display.displayText("TEST SIGNLED", PA_CENTER, 70, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
Serial.begin(9600);
}
void loop() {
//if (Display.displayAnimate()) {
// mendeklarasikan nilai analog ke dalam variabel light
int statusbtn1 = digitalRead(BTN_PIN1);
int statusbtn2 = digitalRead(BTN_PIN2);
//volt / tegangan
// float voltage = light / 4095. * 5;
// hambatan
//float resistance = 2000 * voltage / (1 - voltage / 5);
// lux merupakan satuan turunan SI dari pencahayaan dan daya pancar cahaya
//float lux = pow(RL10 * 1e3 * pow(10, GAMMA) / resistance, (1 / GAMMA));
// Serial.print("analog: ");
//Serial.print(light);
//Serial.print(" lux: ");
//Serial.println(lux);
if (Display.displayAnimate()) {
//Display.displayAnimate();
if (digitalRead(BTN_PIN1)) {
Serial.println(" => kiri");
Display.displayText("<<<< BELOK KIRI ", PA_CENTER, 10, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
}else
if(digitalRead(BTN_PIN2)){
Serial.println(" => Kanan");
Display.displayText("BELOK KANAN >>>> ", PA_CENTER, 10, 0, PA_SCROLL_RIGHT, PA_SCROLL_RIGHT);
}else{
inFX = (inFX + 1) % ARRAY_SIZE(effect);
Serial.println(" => MAJU TERUS");
//Display.displayText("AMAN", PA_CENTER, 70, 0, effect[inFX], effect[outFX]);
//delay(1000);
Display.displayText("JAGA JARAK", PA_CENTER, 70, 0, effect[inFX], effect[outFX]);
}
delay(500);
Display.displayReset();
}}