#include <liquidcrystal.h>
const int Ledredpin = 9; // Красный цвет с ~ const int indbluepin = 10; // Синий цвет с цветом ~ const int ind ledgreenpin = 11; // зеленый цвет с ~
const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2; Liquidcrystal LCD (RS, EN, D4, D5, D6, D7);
const int buttonok = 8; // pushbutton pin pin const int buttonless = 12; // push -pin pin const int int buttonmore = 13; // pushbutton pin
int buttonstateok; int buttonstatemore; Int Buttonstateless;
const int photosensEnpinfirst = 0; // аналоговый входной штифт const int photoersEnspinsecond = 1; // аналоговый входной штифт
int lightlevelfirst; int lightlevelsecond;
без знака длинный временный состав; без знака длинный временный временный интерфейс = 0; без знака длиннопаса; без знака длинная временная томана; без знака длинная сроки; Bool IspaUsed = false;
Bool isrunning = false; bool firstrun = true; int numberofpeople = 1; const char blank [17] = {""};
void setup () {// настройка LCD Colums/Rows Lcd.begin (16, 2); Lcd.print ("Добро пожаловать"); // pushbuttons PIN -входы PinMode (Buttonok, Input); pinmode (buttonmore, input); pinmode (кнопка без кнопки, вход);
// Светодиодный вывод выходов PinMode (LedredPin, Output); PinMode (LEDBLUEPIN, выход); pinmode (ledgreenpin, выход);
}
void loop () {sensorreadings ();
if (buttonstateok == high && firstrun) {isrunning = true; } if (isrunning) {modeselection ();
}
DisplaySwitch (1); if (buttonstateok == high &&! isrunning) {theend (); }
}
void theend () {timePassed = millis () -timeStart -tepaUsed; timetempone = millis ()-timeStart; Timetemptwo = TimePassed/Timetempone; временный экземпляр *= 100; DisplaySwitch (2);
if (timetemptwo <= 40) {DigitalWrite (LedredPin, High);
} if (timempeMemptwo> 40 && timetEmptwo <70) {DigitalWrite (LedBluePin, High);
} if (timempeMemptwo> = 70) {DigitalWrite (Ledgreenpin, High);
}} void sensorreadings () {buttonstateok = DigitalRead (buttongok); ButtonStateMore = DigitalRead (Buttonmore); ButtonStateLess = DigitalRead (Buttonless); Lightlevelfirst = Analogread (Photoerensorpinpirst); LightlevelSecond = Analogread (PhotosensorpInseCond); }
void chectlight () {if (lightlevelfirst> = 800 &&! ispaused) {pauseevent (ispaused);
isPaused = true;
} else {if (lightlevelfirst <800) {pauseevent (ispaused); ispaused = false; }
} if (lightlevelSecond> = 800 &&! ispaused) {pauseevent (ispaused);
isPaused = true;
} else {if (lightlevelSecond <800) {pauseevent (ispaUsed); ispaused = false; }
}} void pauseevent (bool IspaUsed) {if (ispaUsed) {timetEmptwo = millis ();
timePaused += timeTempTwo-timeTempOne;
} else {timetempone = millis (); }
}
void displayswitch (int mode) {char temp [] = ""; Switch (mode) {case 0:
Lcd.setcursor (0,0); //lcd.print(blank); lcd.print («номер игрока:»);
Lcd.setcursor (0,1); // lcd.print (blank); lcd.print (numberofpeople); lcd.display (); перерыв;
case 1:
lcd.setCursor(0,0);
//lcd.print(blank);
lcd.print("Time Passed:");
lcd.setCursor(0,1);
// lcd.print (blank); Lcd.print (Millis ()-TimeStart); lcd.display (); перерыв;
case 2:
lcd.setCursor(0,0);
//lcd.print(blank);
lcd.print("Success Rate:");
lcd.setCursor(0,1);
// lcd.print (blank); lcd.print (timepassed); lcd.display (); перерыв;
default:
lcd.setCursor(0,0);
// lcd.print (blank); Lcd.setcursor (0,1); // lcd.print (blank); lcd.display (); }
}
void lightshow () {DigitalWrite (Ledredpin, High); задержка (100); Digitalwrite (Ledgreenpin, High); задержка (100); Digitalwrite (Ledbluepin, High); задержка (100); Digitalwrite (Ledredpin, Low); задержка (100); DigitalWrite (Ledgreenpin, Low); задержка (100); DigitalWrite (Ledbluepin, Low);
}
void -medeselection () {
if(firstRun)
{
lightShow();
firstRun= false;
}
do {displayswitch (0); if (buttonstatemore == High && numberOpeople <7) {numberOfpeople ++; }
if(buttonStateLess == HIGH && numberOfPeople>1)
{
numberOfPeople--;
}
if(buttonStateOk == HIGH)
{
isRunning=false;
timeStart = millis();
}
} while (isrunning);
}