Hello, a part of my code has a loop where I add 5 to a value for every button press (0->5->10->etc.). It works, but whenever I press the button for about a second, the value increases by hundreds. It seems like the button goes high, low, high, low, etc. very quickly until i let go of the button. Is there a way to limit the state change to just 1 per press? For example, a 1 second press would only add 5. same as a 12 sec press, it would add only 5 to the value.
int holding=3
int value=0;
while (holding==3){
GLCD.CursorToXY(70, 45);
GLCD.print(value);
val1=digitalRead(button1);
if (val1==LOW){value=value+5;}
}