//youtube: skill make
//If you have any problems, ask me in the comments section, I will try to answer quickly
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
int x = 0;
int input = A0;
int state = 0;
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup()
{
lcd.init(); // initialize the lcd
pinMode(7, INPUT); // IR sensor input
pinMode(5, INPUT); // PUSH button switch input
// Print a message to the LCD.
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Count");
lcd.setCursor(0, 8);
lcd.print(x);
}
void loop()
{
int counter = digitalRead(7);
if (state == 0)
{
switch (counter) {
case 1 : state = 1; lcd.setCursor (0, 1); x = x+1; lcd.print(x); break;
case 0 : state = 0; break;
}
}
if (counter == LOW) {
state = 0;
}
if(digitalRead(5) == 1){
x = 0;
}
}