// instead of String you can use char*
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,10,9,8,7);
int button1 = 1;
int button2 = 2;
int button3 = 3;
int m = false;
int x;
void setup() {
// put your setup code here, to run once:
lcd.begin(16,2);
pinMode(button1, INPUT_PULLUP);
pinMode(button2, INPUT_PULLUP);
pinMode(button3, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
int buttonState1 = digitalRead(button1);
int buttonState2 = digitalRead(button2);
int buttonState3 = digitalRead(button3);
if(buttonState1 == LOW & m == false){
lcd.setCursor(0,0);
m = !m;
x++;
delay(300);
}
if(buttonState2 == LOW & m == false){
lcd.setCursor(0,0);
m = !m;
x--;
delay(300);
}
if(buttonState3 == LOW & m == false){
lcd.setCursor(0,0);
m = !m;
x = 0;
delay(300);
}
buttonState1 = digitalRead(button1);
buttonState2 = digitalRead(button2);
buttonState3 = digitalRead(button3);
if(buttonState1 == HIGH & m == true){
if(buttonState2 == HIGH & m == true){
if(buttonState3 == HIGH & m == true){
m = !m;
lcd.clear();
delay(300);
}
}
}
lcd.setCursor(0,0);
lcd.print(x);
}