Multi-function pushbutton
Posted: Mon Jan 29, 2018 11:28 am
So I've gotten a new moped and thought of adding a multi-function pushbutton, that works in the way of pushing the button X amount of times within 5 seconds i.e 1 push within 5 seconds turns on some neon lights with a relay, 2 pushes turns on a speaker in the seat etc. And of course it should be able to toggle them off again with same amount of pushes for the corresponding action.
To do this my friend suggested using millis to count to 5 after the first push, detecting the number of inputs from the button within those seconds, resetting millis after 5 seconds until pushing it again and executing the action.
So I'm quite lost on how to reset millis when the 5'th second is hit and counting the inputs within these seconds.
The counting of pushes I think should be a simple integer that executes "if".
I hope you guys could help me some. All suggestions are appreciated.
To do this my friend suggested using millis to count to 5 after the first push, detecting the number of inputs from the button within those seconds, resetting millis after 5 seconds until pushing it again and executing the action.
So I'm quite lost on how to reset millis when the 5'th second is hit and counting the inputs within these seconds.
The counting of pushes I think should be a simple integer that executes "if".
I hope you guys could help me some. All suggestions are appreciated.