#include <liquidcrystal.h>
const int ledRedPin = 9; // rote Farbstift mit ~ const int ledbluepin = 10; // blaue Farbstift mit ~ const int ledgreenpin = 11; // grüne Farbstift mit ~
const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2; Liquidcrystal LCD (RS, EN, D4, D5, D6, D7);
const int int buttoK = 8; // pushbutton pin const int int buttonless = 12; // Pushbutton Pin const int buttmore = 13; // PushButton Pin
int buttonStateok; int buttonStatemore; Int ButtonSteless;
const int Photosensorpinfirst = 0; // Analogeingang Pin Const Int Photosensorpinsecond = 1; // Analogeingang Pin
int lightlevelfirst; int lightlevelSecond;
nicht signierter langer Zeitstart; nicht signiert long timateured = 0; nicht signierte lange Zeit; nicht signiertes langes Timetempone; nicht signierter langer Zeitplan; bool ispAusused = false;
bool isrunning = false; bool erstrun = true; int nummerofpeople = 1; const char Blank [17] = {""};
void setup () {// lcd setup colums/zeilen lcd.begin (16, 2); LCD.Print ("Willkommen"); // Pushbuttons Pin -Eingänge PinMode (Button, Eingabe); PinMode (Buttonmore, Eingabe); PinMode (Taste, Eingabe);
// LED -Pin -Ausgänge PinMode (LEDREDPIN, Ausgang); PinMode (Ledbluepin, Ausgang); PinMode (Ledgreenpin, Ausgang);
}
void Loop () {SensorReadings ();
if (buttonStateOK == High && firstrun) {isrunning = true; } if (isrunning) {Modeselection ();
}
DisplaySwitch (1); if (buttonStateok == High &&! Isrunning) {theend (); }
}
void theend () {timEpassed = millis () -Timestart -Timepause; timetempone = millis ()-timestart; timetemptwo = timEpassed/timetempone; timetemptwo *= 100; DisplaySwitch (2);
if (timetemptwo <= 40) {digitalwrite (ledReDpin, hoch);
} if (timetemptwo> 40 && timetemptwo <70) {digitalWrite (Ledbluepin, High);
} if (timetemptwo> = 70) {digitalWrite (Ledgreenpin, High);
}} void sensorReadings () {buttonStateOK = digitalread (buttonok); buttonStatemore = digitalread (buttonmore); buttonStaLess = digitalRead (buttonlos); LightleVelfirst = AnalOgrad (Photosensorpinfirst); LightlevelSecond = AnalOgrad (Photosensorpinsekunden); }
void checkLight () {if (lightlevelfirst> = 800 &&!
isPaused = true;
} else {if (lightlevelfirst <800) {PUSEEvent (iSpauded); ispaudiert = false; }
} if (lightlevelSecond> = 800 &&!
isPaused = true;
} else {if (helllevelSecond <800) {PUSEEvent (iSpauded); ispaudiert = false; }
}} void pauseEvent (bool isspAusused) {if (isspauded) {timetemptwo = millis ();
timePaused += timeTempTwo-timeTempOne;
} else {timetempone = millis (); }
}
void displayswitch (int modus) {char temp [] = ""; Switch (Modus) {Fall 0:
LCD.SetCursor (0,0); //lcd.print(blank); lcd.print ("Spielernummer:");
LCD.SetCursor (0,1); // lcd.print (leer); lcd.print (numberofpeople); lcd.display (); brechen;
case 1:
lcd.setCursor(0,0);
//lcd.print(blank);
lcd.print("Time Passed:");
lcd.setCursor(0,1);
// lcd.print (leer); lcd.print (millis ()-timestart); lcd.display (); brechen;
case 2:
lcd.setCursor(0,0);
//lcd.print(blank);
lcd.print("Success Rate:");
lcd.setCursor(0,1);
// lcd.print (leer); lcd.print (timEpassed); lcd.display (); brechen;
default:
lcd.setCursor(0,0);
// lcd.print (leer); LCD.SetCursor (0,1); // lcd.print (leer); lcd.display (); }
}
void lightshow () {digitalWrite (ledReDpin, hoch); Verzögerung (100); DigitalWrite (Ledgreenpin, hoch); Verzögerung (100); DigitalWrite (Ledbluepin, hoch); Verzögerung (100); DigitalWrite (LEDREDPIN, LOW); Verzögerung (100); DigitalWrite (Ledgreenpin, niedrig); Verzögerung (100); DigitalWrite (Ledbluepin, niedrig);
}
void modeselection () {
if(firstRun)
{
lightShow();
firstRun= false;
}
do {displaysWitch (0); if (buttonStatemore == High && numberOfPeople <7) {numberOfPeople ++; }
if(buttonStateLess == HIGH && numberOfPeople>1)
{
numberOfPeople--;
}
if(buttonStateOk == HIGH)
{
isRunning=false;
timeStart = millis();
}
} während (isrunning);
}