#include <LiquidCrystal_I2C.h>
#include <Wire.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
int velocidad(analogRead(A1));
int tiempo(analogRead(A2));
const int BON = 8;
const int BOFF = 7;
int TempsMqnt = 0;
void setup() {
lcd.init();
lcd.clear();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Tec de Monterrey");
lcd.setCursor(0, 1);
lcd.print("Velocidad = ");
lcd.setCursor(0, 2);
lcd.print("Tiempo = ");
lcd.setCursor(0, 3);
lcd.print("Tiempo restante = ");
pinMode(BON, INPUT);
pinMode(BOFF, INPUT);
}
void loop() {
FuncOFF();
}
void FuncOFF() {
lcd.setCursor(19, 0);
lcd.print("1");
while (digitalRead(BON) == LOW){
lcd.setCursor(12, 1);
if (analogRead(A1) != velocidad) {
lcd.print(" ");
}
lcd.setCursor(12, 1);
velocidad = analogRead(A1);
lcd.print(velocidad);
lcd.setCursor(10, 2);
if (analogRead(A2) != tiempo) {
lcd.print(" ");
}
lcd.setCursor(10, 2);
tiempo = analogRead(A2);
lcd.print(tiempo);
}
TempsMqnt = tiempo;
FuncON();
}
void FuncON() {
lcd.setCursor(19, 0);
lcd.print("2");
while ((digitalRead(BOFF) == LOW) && (TempsMqnt != 0)){
lcd.setCursor(12, 1);
if (analogRead(A1) != velocidad) {
lcd.print(" ");
}
lcd.setCursor(12, 1);
velocidad = analogRead(A1);
lcd.print(velocidad);
if ((millis() % 1000) == 0){
TempsMqnt = TempsMqnt - 1;
lcd.setCursor(17, 3);
lcd.print(" ");
lcd.setCursor(17, 3);
lcd.print(TempsMqnt);
}
}
}