#Include <LiquidCrystal.h>
const int ledredpin = 9; // pin de color rojo con ~ const int ledbluePin = 10; // pin de color azul con ~ const int ledgreenpin = 11; // pin verde con ~
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 const int buttonless = 12; // pushbutton pin const int buttonmore = 13; // Pushbutton Pin
int ButtonStateok; int ButtonStatemore; int Buttonstateless;
const int PhotosensRoRpinFirst = 0; // Pin de entrada analógica const int PhotosensorPinSecond = 1; // Pin de entrada analógica
int lighlevelfirst; int lightlevelSecond;
sin firmar a tiempo de tiempo largo; Timapado largo sin firmar = 0; sin firmar largos tiempo de tiempo; Timetempone largo sin firmar; Timetemptwo largo sin firmar; bool ispaused = false;
bool isrunning = false; bool firstrun = true; int numberOfPeople = 1; const char blank [17] = {""};
setup () {// LCD Configuración COLUMS/ROWS LCD.BEGIN (16, 2); lcd.print ("bienvenido"); // Pushbutton Pin entradas PinMode (Buttonok, Entrada); PinMode (Buttonmore, Entrada); PinMode (sin botón, entrada);
// sale de pin de LED pinMode (Ledredpin, salida); PinMode (LedBluePin, salida); PinMode (Ledgreenpin, salida);
}
bucle void () {sensorReadings ();
if (buttonstateok == high && firstrun) {isRunning = true; } if (isRunning) {modeSelection ();
}
DisplaySwitch (1); if (buttonStateok == high &&! Isrunning) {theend (); }
}
vacío theend () {timePassed = millis () -timStart -timePaused; TIMETEMPOne = Millis ()-TimeStart; TIMETEMPTWO = TIMEPASSED/TIMETEMPONE; timetemptwo *= 100; DisplaySwitch (2);
if (TIMETEMPTWO <= 40) {DigitalWrite (LedRedPin, High);
} if (TIMETEMPTWO> 40 && TIMETEMPTWO <70) {DigitalWrite (LedBluePin, High);
} if (TIMETEMPTWO> = 70) {DigitalWrite (LedgreenPin, High);
}} void sensorReadings () {ButtonStateok = DigitalRead (Bottonok); ButtonStateMore = DigitalRead (Buttonmore); ButtonStateless = DigitalRead (sin botones); lightlevelfirst = analogread (PhotosensorPinFirst); LightLevelSecond = Analogread (PhotosSensorPinSecond); }
void checklight () {if (lighlevelfirst> = 800 &&! ispaused) {pauseeVent (ispaused);
isPaused = true;
} else {if (lighlevelfirst <800) {pauseeVent (ispaused); ispaused = falso; }
} if (lightlevelSecond> = 800 &&! ispaused) {pauseeVent (ispaused);
isPaused = true;
} else {if (LightLevelSecond <800) {pauseVent (ispaused); ispaused = falso; }
}} void pauseeVent (bool ispaused) {if (ispaused) {timetEptwo = millis ();
timePaused += timeTempTwo-timeTempOne;
} else {timetEmpone = Millis (); }
}
void displayswitch (int -mod) {char temp [] = ""; Switch (Modo) {Caso 0:
LCD.SetCursor (0,0); //lcd.print(blank); LCD.print ("Número de reproductor:");
LCD.SetCursor (0,1); // lcd.print (en blanco); lcd.print (numberOfPeople); lcd.display (); romper;
case 1:
lcd.setCursor(0,0);
//lcd.print(blank);
lcd.print("Time Passed:");
lcd.setCursor(0,1);
// lcd.print (en blanco); lcd.print (millis ()-timeStart); lcd.display (); romper;
case 2:
lcd.setCursor(0,0);
//lcd.print(blank);
lcd.print("Success Rate:");
lcd.setCursor(0,1);
// lcd.print (en blanco); LCD.print (TimePassed); lcd.display (); romper;
default:
lcd.setCursor(0,0);
// lcd.print (en blanco); LCD.SetCursor (0,1); // lcd.print (en blanco); lcd.display (); }
}
void lightshow () {DigitalWrite (LedRedpin, High); retraso (100); DigitalWrite (Ledgreenpin, High); retraso (100); DigitalWrite (Ledbluepin, High); retraso (100); DigitalWrite (LedRedpin, Low); retraso (100); DigitalWrite (Ledgreenpin, Low); retraso (100); DigitalWrite (Ledbluepin, bajo);
}
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();
}
} while (isRunning);
}