-
Notifications
You must be signed in to change notification settings - Fork 0
GetButton()
Arnd edited this page Dec 13, 2016
·
1 revision
This function will return the number of button presses that have been detected since the last call to the function. The counter is reset to 0 by this function.
While the library trusts that a hardware debounce has been done, it will still perform its own simple checking which merely assumes that any repeated signals within 150ms of each other count as a single push.
// Instantiate the class using all of the pins defined in constants //
EncoderClass Encoder(ROTARY_PIN_1, ROTARY_PIN_2, PUSHBUTTON_PIN, RED_PIN,
GREEN_PIN, BLUE_PIN);
void setup() {
Serial.begin(115200);
delay(1000);
} // of method setup()
void loop(){
uint8_t presses = Encoder.GetButton(); // See how often button was pressed //
if (presses>0) { // If the button was pushed, //
Serial.print(presses); // Display the value //
if (presses==1) Serial.println(" press.");
else Serial.println(" presses.");
} // of if-then we have one or more button presses
} // of method loop()