PatrykW wrote:Mate, you want to do some debouncing there. Connections never perfect and virtually everything has some electrical charge. Try using this:
https://github.com/thomasfredericks/Bounce2
Works for me like a charm
I will try the debounce lib that you linked. I doubt that it will work though, as there is no logic to debounce on. If it just went from LOW to HIGH very quickly a couple of times and ended on HIGH, that would be fine, because there is a "logic" to that. But in my case, the PIN just randomly switches between LOW and HIGH when I touch it. Almost like was floating. Also, the lib that you sent does not seem to be using interrupts, which is bad in my opinion. Checking the PIN-status in every loop is "bad" coding. An interrupt should be used that only triggers when there is a status-change on a PIN. Then the debounce code should be put there.