Loop is executed very frequently. Instead of incrementing the counter when the switch is HIGH, you need to increment if it is HIGH and was LOW. In other words, a transition.
Loop is executed very frequently. Instead of incrementing the counter when the switch is HIGH, you need to increment if it is HIGH and was LOW. In other words, a transition.