// testshapes demo for RGBmatrixPanel library.
// Demonstrates the drawing abilities of the RGBmatrixPanel library.
// For 32x64 RGB LED matrix.
// WILL NOT FIT on ARDUINO UNO -- requires a Mega, M0 or M4 board
#include <RGBmatrixPanel.h>
// Most of the signal pins are configurable, but the CLK pin has some
// special constraints. On 8-bit AVR boards it must be on PORTB...
// Pin 11 works on the Arduino Mega. On 32-bit SAMD boards it must be
// on the same PORT as the RGB data pins (D2-D7)...
// Pin 8 works on the Adafruit Metro M0 or Arduino Zero,
// Pin A4 works on the Adafruit Metro M4 (if using the Adafruit RGB
// Matrix Shield, cut trace between CLK pads and run a wire to A4).
// #define CLK 8 // USE THIS ON ADAFRUIT METRO M0, etc.
//#define CLK A4 // USE THIS ON METRO M4 (not M0)
#define CLK 11 // USE THIS ON ARDUINO MEGA
#define OE 9
#define LAT 10
#define A A0
#define B A1
#define C A2
#define D A3
#define tasterein 5
#define tasteraus 4
#define relay 10
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false, 64);
int Platz1 = 380; //Varaiblen Bestenlliste
int Platz2 = 250;
int Platz3 = 175;
int maxValue = 200;
boolean bestenliste = false;
int Leistung = 280;
int hoehe = 54;
void setup() {
Serial.begin (9600); //Serielle kommunikation starten, damit man sich später die Werte am serial monitor ansehen kann.
pinMode(tasterein, INPUT_PULLUP); //Tasterdefinition
pinMode(tasteraus, INPUT_PULLUP);
pinMode(relay, OUTPUT);
matrix.begin();
matrix.setTextSize(1); // size 1 == 8 pixels high
matrix.setTextWrap(false);
}
void loop() {
if(bestenliste == false){
if(maxValue>=Platz1){ //Bestenliste vergleich akuteller Wert mit Platz 1,2 und 3
Platz3 = Platz2;
Platz2 = Platz1;
Platz1 = maxValue;
}else if(maxValue>=Platz2 && maxValue<=Platz1){
Platz3 = Platz2;
Platz2 = maxValue;
}else if(maxValue>Platz3 && maxValue<=Platz2){
Platz3 = maxValue;
}
bestenliste = true;
matrix.fillScreen(0);
matrix.setCursor(2, 0); // First line written in gold
matrix.setTextColor(matrix.Color888(255,140,0));
matrix.print("#P1:");
matrix.setCursor(28, 0);
matrix.setTextColor(matrix.Color888(255,140,0));
matrix.print(Platz1);
matrix.setCursor(48, 0);
matrix.setTextColor(matrix.Color888(255,140,0));
matrix.println("W");
matrix.setCursor(2, 8); // secound line written in silver
matrix.setTextColor(matrix.Color888(192,192,192));
matrix.print("#P2:");
matrix.setCursor(28, 8);
matrix.setTextColor(matrix.Color888(192,192,192));
matrix.print(Platz2);
matrix.setCursor(48, 8);
matrix.setTextColor(matrix.Color888(192,192,192));
matrix.println("W");
matrix.setCursor(2, 16); // third line writeen in bronce
matrix.setTextColor(matrix.Color888(225,110,0));
matrix.print("#P3:");
matrix.setCursor(28, 16);
matrix.setTextColor(matrix.Color888(225,110,0));
matrix.print(Platz3);
matrix.setCursor(48, 16);
matrix.setTextColor(matrix.Color888(225,110,0));
matrix.println("W");
matrix.setCursor(2, 24); // fourth line written in green
matrix.setTextColor(matrix.Color888(0,150,0));
matrix.print("Sie:");
matrix.setCursor(28, 24);
matrix.setTextColor(matrix.Color888(0,150,0));
matrix.print(maxValue);
matrix.setCursor(48, 24);
matrix.setTextColor(matrix.Color888(0,150,0));
matrix.println("W");
}
if(digitalRead(tasterein)==LOW){
digitalWrite(relay, HIGH);
while(digitalRead(tasteraus)==HIGH){
matrix.fillScreen(0);
matrix.setCursor(5, 0); // First line written in red
matrix.setTextColor(matrix.Color888(255,0,0));
matrix.println("Leistung:");
matrix.setCursor(17, 8); // secound line written in red
matrix.setTextColor(matrix.Color888(255,0,0));
matrix.println(Leistung);
matrix.setCursor(14, 16); // thiid line written in green
matrix.setTextColor(matrix.Color888(0,255,0));
matrix.println("Hoehe:");
matrix.setCursor(17, 24); // fourth line written in green
matrix.setTextColor(matrix.Color888(0,255,0));
matrix.println(hoehe);
}
bestenliste = false;
digitalWrite(relay, LOW);
}
}