#include <LiquidCrystal_I2C.h>
#define BTN1 5
#define BTN2 4
LiquidCrystal_I2C lcd(0x27,16,2);
int a = 0; // кількість молока
float result = 0;
const float percentage = 9.00;
void setup() {
lcd.init();
lcd.clear();
lcd.backlight();
pinMode(BTN1, INPUT_PULLUP);
pinMode(BTN2, INPUT_PULLUP);
lcd.setCursor(0,0);
lcd.print("Press red button");
}
void loop() {
if(digitalRead(BTN1)==LOW){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Input milk mass");
delay(500);
a = a + 1;
lcd.setCursor(0,1);
lcd.print(String(a) + "kg");
}
if(digitalRead(BTN2)==LOW){
result = a * percentage / 100;
lcd.clear();
lcd.setCursor(0,0);
lcd.print(String(result) + "kg");
}
}