#include <LiquidCrystal.h>
#include "Button.h"
Button incrementButton(A0);
Button decrementButton(A1);
Button resetButton(A2);
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
int counter = 0;
const int relaySwitch = 3;
void setup() {
pinMode(relaySwitch, OUTPUT);
lcd.begin(16, 2);
lcd.print("WELCOME");
delay(500);
}
void loop() {
if (incrementButton.pressed()) {
counter++;
lcd.clear();
lcd.print(counter);
}
if (decrementButton.pressed()) {
counter--;
if(counter<0){
counter = 0;
}
lcd.clear();
lcd.print(counter);
}
if (resetButton.pressed()) {
counter=0;
lcd.clear();
lcd.print(counter);
}
if(counter==10){
digitalWrite(relaySwitch, HIGH);
} else {
digitalWrite(relaySwitch, LOW);
}
}