Размер видео: 1280 X 720853 X 480640 X 360
Показать панель управления
Автовоспроизведение
Автоповтор
❤❤❤❤❤ 0:21
#include const int SHORT_PRESS_TIME = 1000; // 1000 millisecondsconst int LONG_PRESS_TIME = 1000; // 1000 millisecondsezButton button(7); // create ezButton object that attach to pin 7;unsigned long pressedTime = 0;unsigned long releasedTime = 0;bool isPressing = false;bool isLongDetected = false;void setup() { Serial.begin(9600); button.setDebounceTime(50); // set debounce time to 50 milliseconds}void loop() { button.loop(); // MUST call the loop() function first if(button.isPressed()){ pressedTime = millis(); isPressing = true; isLongDetected = false; } if(button.isReleased()) { isPressing = false; releasedTime = millis(); long pressDuration = releasedTime - pressedTime; if( pressDuration < SHORT_PRESS_TIME ) Serial.println("short press is detected");// press < long is short(1000) } if(isPressing == true && isLongDetected == false) { long pressDuration = millis() - pressedTime; if( pressDuration > LONG_PRESS_TIME ) { Serial.println("long press is detected");//press > short is long(1000) isLongDetected = true; } }}
❤❤❤❤❤ 0:21
#include
const int SHORT_PRESS_TIME = 1000; // 1000 milliseconds
const int LONG_PRESS_TIME = 1000; // 1000 milliseconds
ezButton button(7); // create ezButton object that attach to pin 7;
unsigned long pressedTime = 0;
unsigned long releasedTime = 0;
bool isPressing = false;
bool isLongDetected = false;
void setup() {
Serial.begin(9600);
button.setDebounceTime(50); // set debounce time to 50 milliseconds
}
void loop() {
button.loop(); // MUST call the loop() function first
if(button.isPressed()){
pressedTime = millis();
isPressing = true;
isLongDetected = false;
}
if(button.isReleased()) {
isPressing = false;
releasedTime = millis();
long pressDuration = releasedTime - pressedTime;
if( pressDuration < SHORT_PRESS_TIME )
Serial.println("short press is detected");// press < long is short(1000)
}
if(isPressing == true && isLongDetected == false) {
long pressDuration = millis() - pressedTime;
if( pressDuration > LONG_PRESS_TIME ) {
Serial.println("long press is detected");//press > short is long(1000)
isLongDetected = true;
}
}
}