#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define LCD_ADDR 0x27
#define BUTTON_PIN 9
#define ADD_BUTTON_PIN 4
LiquidCrystal_I2C lcd(LCD_ADDR, 16, 2);
unsigned long lastButtonPressTime = 0;
unsigned long lastAddButtonPressTime = 0;
unsigned int buttonPressCount = 0;
unsigned int totalJobsDone = 0;
void setup() {
lcd.begin(16, 2);
lcd.backlight();
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(ADD_BUTTON_PIN, INPUT_PULLUP);
}
void loop() {
unsigned long currentTime = millis();
// Check if the button is pressed
if (digitalRead(BUTTON_PIN) == LOW) {
if (currentTime - lastButtonPressTime >= 200) {
buttonPressCount++;
lastButtonPressTime = currentTime;
}
}
// Check if the add button is pressed
if (digitalRead(ADD_BUTTON_PIN) == LOW) {
if (currentTime - lastAddButtonPressTime >= 2000) {
totalJobsDone += buttonPressCount;
buttonPressCount = 0;
lastAddButtonPressTime = currentTime;
}
}
// Check if more than a minute has passed without button press
if (currentTime - lastButtonPressTime >= 60000) {
buttonPressCount = 0;
}
// Display counts on the LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Job Cout: " + String(buttonPressCount));
lcd.setCursor(0, 1);
lcd.print("Total Jobs: " + String(totalJobsDone));
delay(100); // Adjust delay based on your needs
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
lcd1:GND
lcd1:VCC
lcd1:SDA
lcd1:SCL
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r
gnd1:GND
btn2:1.l
btn2:2.l
btn2:1.r
btn2:2.r