So we built a counter in school with a lcd attached to it.
When i press a button the counter goes up by 1 how its supposed to be.
The problem is that when I keep the button pressed, the counter will go up the whole time.Tekst sformatowany
In conclusion, does someone know how to fix this?, it should only go up by 1 no matter how long i will keep the button pressed.
Heres the script:
#include <LiquidCrystal.h>
int button=8;
int val;
int count=0;
int press;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.begin(16, 2);
pinMode(8,INPUT);
}
void loop() {
val=digitalRead(button);
if(val==HIGH){
press=count++;
delay(250);
}
lcd.setCursor(0, 0);
lcd.print("Counter");
lcd.setCursor(0, 1);
lcd.print(press);
}