3.MultiPurposeButton
This examples shows how to use the MultiPurposeButton class to detect different kinds of push button events.
- Boards: 🛈
- AVR, AVR USB, Nano Every, Nano 33 IoT, Nano 33 BLE, UNO R4, Pi Pico, Due, Teensy 3.x, ESP8266, ESP32
Connections
- 2: Momentary push button (other pin to ground)
The internal pull-up resistor will be enabled.
Behavior
- Short presses, long presses, multiple presses, etc. are printed to the Serial monitor.
Written by PieterP, 2022-05-07
https://github.com/tttapa/Arduino-Helpers
btn.setLongPressDelay(1000);
btn.setMultiPressDelay(400);
}
void loop() {
case btn.ShortPressRelease:
break;
case btn.LongPressRelease:
break;
Serial <<
"Consecutive presses: " <<
btn.getCurrentMultiPressCount() + 1
break;
Serial <<
"Counted " <<
btn.getMultiPressCount() + 1
<<
" consecutive presses" <<
endl;
break;
}
}
Dummy header file for Arduino builder.
Array< T, N > copyAs(const Array< U, N > &src)
Copy an Array to an Array of a different type.
Print & endl(Print &printer)