Answer the question
In order to leave comments, you need to log in
How to do isRelease correctly?
I work with the Gaver Button library. A very good library from my point of view, but there was a problem with which I can not get along. Here is an outline of the problem:
#define BTN_PIN 2
#include "GyverButton.h"
GButton butt1(BTN_PIN);
boolean flag = true;
void setup() {
Serial.begin(9600);
}
void loop() {
butt1.tick();
if (butt1.isStep()) { // Удержание
flag = true;
}
if (butt1.isStep(1)) { // Клик + Удержание
if(flag) flag = false;
}
if (butt1.isRelease()){ // Отпускание кнопки
flag = false;
}
}
Answer the question
In order to leave comments, you need to log in
It is better to ask about the libraries of this friend on his own forum:
https://community.alexgyver.ru/
void loop() {
butt1.tick();
if (butt1.isStep()) { // Hold
flag = true;
}
if (butt1.isStep(1)) { // Click - first
if (butt1.isStep()) { // Hold - then
flag = true;
if (butt1.isRelease()){ // Release the button
flag = false;
}
}
if(flag) flag = false;
}
}
Well, something like this, you need to try to invest Ifa what she will do, but the idea is this.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question