#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define buttonSetUp 3
#define buttonSetDown 4
#define buttonStart 2
#define buttonSet0 5
int counterSet = 0;
int counter = 0;
int buttonSetUp_StateCurrent = LOW;
int buttonSetUp_StatePrevious = LOW;
int buttonSetDown_StateCurrent = LOW;
int buttonSetDown_StatePrevious = LOW;
// int buttonStart_StateCurrent = LOW;
// int buttonStart_StatePrevious = LOW;
int buttonSet0_StateCurrent = LOW;
int buttonSet0_StatePrevious = LOW;
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup(){
Serial.begin(115200);
pinMode(buttonSetUp, INPUT_PULLUP);
pinMode(buttonSetDown, INPUT_PULLUP);
pinMode(buttonStart, INPUT_PULLUP);
pinMode(buttonSet0, INPUT_PULLUP);
lcd.init();
lcd.backlight();
}
void loop(){
buttonSetUp_StatePrevious = buttonSetUp_StateCurrent;
buttonSetUp_StateCurrent = digitalRead(buttonSetUp);
if (buttonSetUp_StatePrevious == LOW && buttonSetUp_StateCurrent == HIGH){
counterSet++;
}
buttonSetDown_StatePrevious = buttonSetDown_StateCurrent;
buttonSetDown_StateCurrent = digitalRead(buttonSetDown);
if (buttonSetDown_StatePrevious == LOW && buttonSetDown_StateCurrent == HIGH){
counterSet--;
}
int buttonStart_State = digitalRead(buttonStart);
if (buttonStart_State == LOW){
counter++;
}
if (counter == counterSet){
counter=0;
}
buttonSet0_StatePrevious = buttonSet0_StateCurrent;
buttonSet0_StateCurrent = digitalRead(buttonSet0);
if (buttonSet0_StatePrevious == LOW && buttonSet0_StateCurrent == HIGH){
counter=0;
lcd.clear();
}
Serial.print(buttonSetUp_StateCurrent);
Serial.print(" a ");
Serial.print(buttonSetDown_StateCurrent);
Serial.print(" b ");
Serial.print(buttonStart_State);
Serial.print(" c ");
Serial.print(buttonSet0_StateCurrent);
Serial.print(" d ");
Serial.print(counterSet);
Serial.print(" e ");
Serial.println(counter);
lcd.setCursor(0,0);
String data = String ("Target = ") + String (counterSet);
lcd.print(data);
lcd.setCursor(0,1);
String data2 = String ("Plastik = ") + String (counter);
lcd.print(data2);
delay(10);
}