Closed alw1746 closed 10 months ago
Support latching switch usage with isPressed function:
In OneButton.h,
bool isPressed() const { return _state == OCS_DOWN; }
In loop(),
button.tick(); if (button.isPressed()) { //switch latched on if (!ledOn) { digitalWrite(LED_BUILTIN,HIGH); ledOn=true; } } else if (button.isIdle()) { //latch released if (ledOn) { digitalWrite(LED_BUILTIN,LOW); ledOn=false; } }
You can use the public isIdle() function for this:
if (! button.isIdle()) { // on } else { // off }
Support latching switch usage with isPressed function:
In OneButton.h,
In loop(),