hello guys, i need help.
i know it is a very basic and simple, but im totaly newbie about arduino coding.
what i want is when you press the button, the response on lcd is "button is: (pressed)" for 20 seconds before disappeared the word (pressed) but if you press button again it result to clear the pressed dispaly without waiting the 20 seconds countdown.
this is the example
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 16, 2);
int ButtonState;
int oldButtonState;
int ledpin2=A1;
int StartButt=7;
void setup(){
lcd.init();
lcd.backlight();
pinMode(StartButt,INPUT);
pinMode(ledpin2,OUTPUT);
}
void loop(){
ButtonState=digitalRead(StartButt);
lcd.setCursor(0,0);
lcd.print("Button is:");
if(ButtonState!=oldButtonState){
if (ButtonState == HIGH) {
lcd.setCursor(0,1);
lcd.print("Pressed:");
delay(20000);
lcd.clear();
}
}
else
if (ButtonState == HIGH) {
delay(100);
lcd.clear();
}
}
code.