Search wiring.org.co:

Libraries \ Button

Reference for Wiring version 1.0 Build 0100+ If you have a previous version, use the reference included with your software. If see any errors or have any comments, let us know.

Class | Button
Name |

### holdHandler()

Examples |
    #include <Button.h>

    /*
      Wire like this:
     GND -----/ button ------ pin 12
     */
    Button button = Button(12,BUTTON_PULLUP_INTERNAL);

    void handleButtonHoldEvents(Button &btn)
    {
      Serial.println("hold");
      for (int i=0; i<10; i++)
      {
        digitalWrite(WLED, HIGH);
        delay(20);
        digitalWrite(WLED, LOW);
        delay(20);
      }
      digitalWrite(WLED, HIGH);
    }

    void setup()
    {
      Serial.begin(9800);
      pinMode(WLED,OUTPUT);

      button.holdHandler(handleButtonHoldEvents,1500);
    }

    void loop()
    {
      button.isPressed(); //update internal state
      /*
       Feel free to do your own processing here.
       The buttons will be handeled 'automagically' by the handler functions
      */
    }
Description | Register a handler for when this button is held.
Syntax |
    holdHandler(handler, holdTime)
Parameters |

handler | buttonEventHandler: The function to call when this button is held
holdTime | unsigned int

Returns | None
Usage | Application

Updated on July 07, 2011 11:09:39pm PDT