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?
-
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. -
@ZenBlizzard , yes thanks, thats the point. How to deal with smartSleep() and battery lifetime.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login