Skip to content

Instantly share code, notes, and snippets.

@rhettc
Last active May 11, 2016 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhettc/125254c246c3c08907c974d6350f7d1d to your computer and use it in GitHub Desktop.
Save rhettc/125254c246c3c08907c974d6350f7d1d to your computer and use it in GitHub Desktop.
Extract Method
void setupButton(int pin, Bounce debouncer)
{
pinMode(pin, INPUT_PULLUP);
// configure the de-bounce for this button
debouncer.attach(pin);
debouncer.interval(5);
}
void setup() {
Serial.begin(19200); //DEBUGGING ONLY
setupButton(BUTTON_PIN_1, debouncer1);
setupButton(BUTTON_PIN_2, debouncer2);
setupButton(BUTTON_PIN_3, debouncer3);
setupButton(BUTTON_PIN_4, debouncer4);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment