MTbutton, push button
Event management for Uno, Nano, Mega

Type button bell, active if you press it, inactive when it is released. Can call functions during support and when relaxing.

Include to add

#include <MTobjects.h> // See http://arduino.dansetrad.fr/en/MTobjects

I strongly advise to leave the comment, if another person wanted to try the program, they would have a download link directly. This is valid for all the libraries you use.

Useful comment

if_not_pressed

This comment is a word that can be added anywhere and which is ignored by the compiler.

Constructor

MTbutton(pin,
         onSelectFunction =  NO_ACTION,
         onUnselectFunction = NO_ACTION,
         rest = HIGH);

Useful variable

bounce

bounce (word): time during which rebounds are ignored. By default 32ms, rounded up to packages of 16ms upper. f.ex. BOUNCE = 50 milli_seconds; gives 64ms maximum rebounds.

Useful functions

boolean getSelect(void);
virtual void onSelect(void);
virtual void onUnselect(void);

getSelect: return true if the button is pushed
onSelect: overload function called when pressing the button
onUnselect: overload function called when releasing the button

Bonus functions

void setOnSelectFunction(onSelectFunction);
void setOnSelectFunction();
void setOnUnselectFunction(onUnselectFunction);
void setOnUnselectFunction();

setOnSelectFunction: changes the function called when pressing the button
setOnSelectFunction: without parameters removes the function called when pressing the button
setOnUnselectFunction: changes the function called during releasing the button
setOnUnselectFunction: without parameters removes the function called when releasing the button

Examples