#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>


#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 4 
#define CLK_PIN    13 
#define Data_PIN   11 
#define CS_PIN     10 

MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
int Pins[] = {2, 3, 4, 5, 6, 7, 8,9}; 
int timer;

void setup() {
  timer = 1;
  for (int i=2;i<=9;i++){
    pinMode(i, OUTPUT);
  }
  myDisplay.begin();
  myDisplay.displayClear();

  digitalWrite(Pins[0], HIGH);
  digitalWrite(Pins[1], LOW);
  digitalWrite(Pins[2], LOW);
  digitalWrite(Pins[3], HIGH);
  digitalWrite(Pins[4], HIGH);
  digitalWrite(Pins[5], HIGH);
  digitalWrite(Pins[6], HIGH);   
  digitalWrite(Pins[7], HIGH);
}

void loop() {
  
    if(myDisplay.displayAnimate()){
      switch (timer){
        case 1:
          digitalWrite(Pins[0], HIGH);
          digitalWrite(Pins[1], LOW);
          digitalWrite(Pins[2], LOW);
          digitalWrite(Pins[3], HIGH);
          digitalWrite(Pins[4], HIGH);
          digitalWrite(Pins[5], HIGH);
          digitalWrite(Pins[6], HIGH);   
          digitalWrite(Pins[7], HIGH);
          myDisplay.displayText
          (" RICKY ZULKARNAIN GAVOER "
          , PA_CENTER, 100, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
          timer=2;
        break;

        case 2:
          digitalWrite(Pins[0], LOW);
          digitalWrite(Pins[1], LOW);
          digitalWrite(Pins[2], HIGH);
          digitalWrite(Pins[3], LOW);
          digitalWrite(Pins[4], LOW);
          digitalWrite(Pins[5], HIGH);
          digitalWrite(Pins[6], LOW);
          myDisplay.displayText
          (" NIM : 124650198 "
          , PA_CENTER, 100, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
          timer=1;
        break;
      }
    }
}