-
Notifications
You must be signed in to change notification settings - Fork 0
Button
Alex Krieg edited this page May 26, 2018
·
12 revisions
- Button(int pinNr);
- Button(int pinNr, unsigned int logicLevel);
- ~Button();
- void update();
- void OnPressedEdge(void (*p_func)());
- void OnReleasedEdge(void (*p_func)());
- void OnBothButtonEdges(void (*p_func)());
- void IsPressedHigh(void (*p_func)());
- void IsPressedLow(void (*p_func)());
- virtual boolean getValue();
- int getPin();
- Constructor
- Needs a pinNr for the button
- Can take logicLevel, default (no param) = activeHigh.
If voltage rises up when the button is pressed,
logicLevel = avtiveHigh
If voltage falls when the button is pressed,logicLevel = activeLow
- You can set the logicLevel as INPUT_PULLUP for the Arduino internal pullup resistor.
Button myButton(3);
Button myButton(3,activeHigh);
Button myButton(3,activeLow);
Button myButton(3,INPUT_PULLUP);
Button myButton(3,pullup);
Button myButton(3,PULLUP);
- Destructor
delete &myButton;
- Reads the state of the button.
- If any event Function is defined, it will run these in certain conditions.
myButton.update();
You do not know how events work?
Look over here
- Is executed when a rising edge of the button is detected.
- NO values accepted.
- NO return values.
- Is executed when a falling edge of the button is detected.
- NO values accepted.
- NO return values.
- Is executed when a any edge of the button is detected.
- NO values accepted.
- NO return values.
- Is executed when the button is pressed.
- NO values accepted.
- NO return values.
- Is executed when the button isn't pressed.
- NO values accepted.
- NO return values.
- Returns the active state of the button pin.
bool state = myButton.getValue();
- Returns the pin on which the button is connected to.
int buttonPin = myButton.getPin();
Wiki
Arduino libraries