#include <LiquidCrystal.h>
LiquidCrystal lcd(18,5,17,16,4,0);
const int btnlnc_1 =12;
const int btnDEC_1 =14;
const int btnlnc_2 =27;
const int btnDEC_2 =26;
const int btnReset =25;
int count1=0,count2=0;
void setup() {
// put your setup code here, to run once:
pinMode(btnlnc_1, INPUT_PULLUP);
pinMode(btnDEC_1, INPUT_PULLUP);
pinMode(btnlnc_2, INPUT_PULLUP);
pinMode(btnDEC_2, INPUT_PULLUP);
pinMode(btnReset, INPUT_PULLUP);
lcd.begin(16,2);
lcd.print("Counter Program");
delay(1000);
update_lcd_count();
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(btnlnc_1)==0){
count1++;
update_lcd_count();
}
if(digitalRead(btnDEC_1)==0){
count1--;
update_lcd_count();
}
if(digitalRead(btnlnc_2)==0){
count2++;
update_lcd_count();
}
if(digitalRead(btnDEC_2)==0){
count2--;
update_lcd_count();
}
if(digitalRead(btnReset)==0){
count1=0;
count2=0;
update_lcd_count();
}
}
void update_lcd_count(void){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Count1:");
lcd.print(count1);
lcd.setCursor(0,1);
lcd.print("Count2:");
lcd.print(count2);
delay(500);
}