#include <LiquidCrystal_PCF8574.h>
LiquidCrystal_PCF8574 lcd(0x27); // set the LCD address to 0x27 for a 16 chars and 2 line display
#define boton_inc 2 //Boton incremento
#define boton_dec 3 //Boton decremento
#define boton_reset 4 //Boton reset
#define estado_boton_inc digitalRead(boton_inc)
#define estado_boton_dec digitalRead(boton_dec)
#define estado_boton_reset digitalRead(boton_reset)
bool estado_boton_inc_ant;
bool estado_boton_dec_ant;
byte contador = 0;
void setup() {
// put your setup code here, to run once:
pinMode(boton_inc, INPUT);
pinMode(boton_dec, INPUT);
pinMode(boton_reset, INPUT);
lcd.begin(20, 4);
delay(200);
lcd.setBacklight(255);
lcd.print("BI: BD: BR:");
lcd.setCursor(0, 1);
lcd.print("Contador:");
}
void loop() {
// put your main code here, to run repeatedly:
if (estado_boton_inc && !estado_boton_inc_ant && contador < 100)
{
contador++;
delay(5);
}
if (estado_boton_inc != estado_boton_inc_ant)
estado_boton_inc_ant = estado_boton_inc;
//Programar conteo descendente
if (estado_boton_reset)
{
contador = 0;
}
lcd.setCursor(3, 0);
lcd.print(estado_boton_inc);
//Programar visualización estado_boton_dec
lcd.print(estado_boton_dec);
lcd.setCursor(15, 0);
lcd.print(estado_boton_reset);
lcd.setCursor(9, 1);
lcd.print(contador);
lcd.print(" ");
delay(50);
}