I try to trigger attachInterrupt() ONCE when i puch a button and make pin 2 to FALLING.
But unfortunately when i push button triggers attachInterrupt() two or more times and sometimes only one.
What happens?
It's called contact bounce. When you press the button, the electrical contacts actually make and break the connection multiple times very quickly. This makes a button a poor interrupt source. Often, there is no need to use attachInterrupt() to detect button presses. Instead, you can poll the input pin in a loop (assuming you don't have blocking code). Even then, you still need to deal with the contact bounce. Contact bounce is an extremely well documented problem in electronics. You will find a tremendous amount of information on this topic and debouncing techniques with just a little research.
To many unknowns here to be able to help.
- Wiring diagram. Could be wiring issue?
- Code. Could be a code issue.
Please provide this information and someone might be able to help.
Hi,
This might help: debounce