single-click, double-click, long-press button possible with MySensors?
-
Hi all,
has anyone yet implemented some kind of multi tap button with MySensors?
Such as single-click, double-click, long-press, ... ?I think, I cannot work with interrupts, as I can get a HIGH/LOW once only and cannot count for long-press? Correct? And a battery mode node cannot be used either (with
smartSleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR_2),...
) because I have to check for e.g. a long-press which might last some seconds ...Thanks in advance for any comment or code example?
-
hey @dirkc, maybe you can trigger your interrupt to rising and falling edge and use millis() to see how long the press was?
-
Yes, it's definitely possible to detect single click, double click, and long press with MySensors. You can use interrupts on both rising and falling edges and track the time with millis() to determine how long the button is held.
For example:
Short press = single click
Two quick presses = double click
Hold longer than a threshold = long press
Just make sure to debounce the button to avoid false triggers. If your node is battery-powered and using smartSleep(), handling long presses can be trickier—might be better to stay awake during the press in that case.
-
..
https://forum.arduino.cc/t/partage-boutons-poussoirs/361656https://forum.arduino.cc/t/tutoriel-la-bibliotheque-onebutton/1136825
-
@ZenBlizzard , yes thanks, thats the point. How to deal with smartSleep() and battery lifetime.