#include <Wire.h>
#include <LiquidCrystal_I2C.h> //libraries for lcd
LiquidCrystal_I2C lcd(0x27,16,2);
//we define variables and constant variables
int ledr=13;//red led
int ledg=12;//green led
const int Buzzer = 11 ;//nuestro zumbador activo
int btn = 10;// our button
void setup(){
//we define the outputs
pinMode(ledr, OUTPUT);
pinMode(ledg, OUTPUT);
pinMode(Buzzer,OUTPUT);
//and the inputs
pinMode(btn,INPUT);
//we start the lcd
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("start ");
}
void loop(){
// leemos el valor del boton si esta encendido inicia la cuenta
if (digitalRead(btn)==HIGH){
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, HIGH);
delay(500);
lcd.setCursor(0, 0);
lcd.print("20 seconds");
lcd.setCursor(0, 1);
lcd.print("remember ");
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("19 seconds");
lcd.setCursor(0, 1);
lcd.print("this can ");
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("18 seconds");
lcd.setCursor(0, 1);
lcd.print("save your ");
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("17 seconds");
lcd.setCursor(0, 1);
lcd.print("life ");
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("16 seconds");
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("15 seconds");
lcd.setCursor(0, 1);
lcd.print("remember ");
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("14 seconds");
lcd.setCursor(0, 1);
lcd.print("this can ");
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("13 seconds");
lcd.setCursor(0, 1);
lcd.print("save your ");
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("12 seconds");
lcd.setCursor(0, 1);
lcd.print("life ");
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("11 seconds");
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("10 seconds");
lcd.setCursor(0, 1);
lcd.print("remember ");
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("9 seconds ");
lcd.setCursor(0, 1);
lcd.print("this can ");
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("8 seconds ");
lcd.setCursor(0, 1);
lcd.print("save your ");
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("7 seconds ");
lcd.setCursor(0, 1);
lcd.print("life ");
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("6 seconds ");
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("5 seconds ");
lcd.setCursor(0, 1);
lcd.print("remember ");
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("4 seconds ");
lcd.setCursor(0, 1);
lcd.print("this can ");
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("3 seconds ");
lcd.setCursor(0, 1);
lcd.print("save your ");
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("2 seconds ");
lcd.setCursor(0, 1);
lcd.print("life ");
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("1 second ");
digitalWrite(ledr, HIGH);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("successful");
lcd.setCursor(0, 1);
lcd.print("washing ");
digitalWrite(ledr, LOW);
digitalWrite(ledg, HIGH);
digitalWrite(Buzzer, HIGH);
delay(500);
lcd.setCursor(0, 0);
lcd.print("successful");
lcd.setCursor(0, 1);
lcd.print("washing ");
digitalWrite(ledr, LOW);
digitalWrite(ledg, HIGH);
digitalWrite(Buzzer, LOW);
delay(500);
lcd.setCursor(0, 0);
lcd.print("successful");
lcd.setCursor(0, 1);
lcd.print("washing ");
digitalWrite(ledr, LOW);
digitalWrite(ledg, HIGH);
digitalWrite(Buzzer, HIGH);
delay(500);
lcd.setCursor(0, 0);
lcd.print("successful");
lcd.setCursor(0, 1);
lcd.print("washing ");
digitalWrite(ledr, LOW);
digitalWrite(ledg, HIGH);
digitalWrite(Buzzer, LOW);
delay(500);
lcd.setCursor(0, 0);
lcd.print("can go out");
lcd.setCursor(0, 1);
lcd.print(" ");
delay(5000);
}
else {
digitalWrite(ledr, LOW);
digitalWrite(ledg, LOW);
digitalWrite(Buzzer, LOW);
lcd.setCursor(0, 0);
lcd.print("start ");
}
}
Comments