I am using a switch that is connected to a digital input.
I want to use the switch as a counter, every time I press the switch, I want the count to increase by one.
I am using a if statement to detect if the switch is high and once it is high I am simply increasing the count:
if (Switch == True)
{
count = count + 1;
}
The problem I am stuck with is that the code loops multiple times while the switch is pressed, this results in a count of more than one for example 11 even if the switch is only pressed once.
any help will be greatly appreciated