#include <MD_MAX72xx.h>
#include <MD_Parola.h>
#include <SPI.h>
// Something.. idk really
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 4
#define CS_PIN 10
#define DATAPIN 11
#define CLK_PIN 13
#define USE_GENERIC_HW 1
//MD_Parola matrix = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, DATAPIN, CLK_PIN, CS_PIN, MAX_DEVICES);
#define mode1 4
#define resetb 2
void setup()
{
pinMode(mode1, INPUT);
pinMode(resetb, INPUT);
// Start the display:
myDisplay.begin();
// Set the intensity (brightness) of the display (0-15):
myDisplay.setIntensity(8);
// Clear the display:
myDisplay.displayClear();
}
void loop(void)
{
//WAITING MODE
//Waits for green button to be pressed
//Then turning on the MODE1 to show some text
myDisplay.setInvert(false);
myDisplay.setTextAlignment(PA_CENTER);
myDisplay.print("Cekam");
if (digitalRead(mode1) == HIGH)
{
text();
}
}
//MODE1
//Does some text things to show it is working
void text()
{
while(true) // loop forever or until check() returns true
{
myDisplay.setTextAlignment(PA_CENTER);
myDisplay.print("Center");
delay(2000);
if (check()) return;
myDisplay.setTextAlignment(PA_LEFT);
myDisplay.print("Left");
delay(2000);
if (check()) return;
myDisplay.setTextAlignment(PA_RIGHT);
myDisplay.print("Right");
delay(2000);
if (check()) return;
myDisplay.setTextAlignment(PA_CENTER);
myDisplay.setInvert(true);
myDisplay.print("Invert");
delay(2000);
if (check()) return;
myDisplay.setInvert(false);
myDisplay.print(1234);
delay(2000);
if (digitalRead(resetb) == HIGH) return;
}
}
bool check() // Check reset button. If pressed short delay and return value of true, else return false
{
if (digitalRead(resetb) == HIGH) // Check Reset button. This one for button with pulldown resistor
// if (!digitalRead(Reset) == HIGH) // This one with "!" if you use pinMode(Reset, INPUT_PULLUP);
{
delay(50); // if pressed then short delay
return true; // and the return value of true to text()
}
return false; // if not pressed ruturn false value to text()
}