I'm trying to write a little code that detects how long a button connected to my Raspberry Pi is pushed down, not just if it's pushed. Is there an easy way to do this with Python? Thanks!
You just have to detect whenever the state of the button is toggled. When toggled if it's pushed down you will need to store the current time with pressedTime = time.time(). When released, to get how long the button have been pushed down, you just do : howLong = time.time() - pressedTime
Detect time button is pushed