-
Hi, all
newbi question I know!!!
How can I perform a double click event with M5 buttons on arduino envirement?
ciao
-
I will start from here:
#include <M5Stack.h> boolean State1 = false; boolean State2 = false; long buttonTimer = 0; long longPressTime = 250; boolean buttonActive = false; boolean longPressActive = false; void setup() { M5.begin(); Serial.begin(115200); } void loop() { if (M5.BtnB. read() == HIGH) { if (buttonActive == false) { buttonActive = true; buttonTimer = millis(); } if ((millis() - buttonTimer > longPressTime) && (longPressActive == false)) { longPressActive = true; State1 = !State1; Serial.println("LONG"); } } else { if (buttonActive == true) { if (longPressActive == true) { longPressActive = false; } else { State2 = !State2; Serial.println("SHORT"); } buttonActive = false; } } M5.update(); } -
M5ez is a complete and very easy to use programming environment that offers many other nice things. Among them, you can very easily define what happens with short press, long press as well as combinations of two buttons.
-
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