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

held()

Examples
#include <Button.h>

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

/*
  Do your regular setup stuff here
 */
void setup()
{
  Serial.begin(9800);
  pinMode(WLED,OUTPUT);
}

void loop()
{
  button.isPressed();
  if (button.stateChanged())
  {
    if (button.wasPressed()) 
    {
      handleButtonPressEvent();
    }
    else 
    {
      Serial.println("release");
      Serial.println("click");
    }
  }
  if (button.held(1500))
  {
    Serial.println("hold");
  }
}
Description Check to see if the button has been pressed for time in milliseconds. This will clear the counter for next iteration and thus return true once.
Syntax
held(time)
Parameters
time unsigned int: Time in milliseconds
Returns Boolean
Usage Application
Updated on July 07, 2011 11:09:38pm PDT

Creative Commons License