MTtripleButton: Example 1
Event management for Uno, Nano, Mega
Flashing
triple clic
A button is connected between A0 and GND. The program will light the LED_BUILTIN LED on triple click and turn it off on a single click.
Complete program recommended
This program is completely under interruption, and releases loop which can be used to do something else.
// The program will light the LED_BUILTIN LED on triple click
// and turn it off on a single click.
#include <MTobjects.h> // V1.0.6 See http://arduino.dansetrad.fr/en/MTobjects
const uint8_t PIN_BUTTON = A0; // Button wired between A0 and GND
void allume(void) // Call on triple-click
{
digitalWrite(LED_BUILTIN, HIGH); // Turn on
}
void eteint(void) // Call on simple-click
{
digitalWrite(LED_BUILTIN, LOW); // Turn off
}
MTtripleButton Bouton(PIN_BUTTON, allume, NO_ACTION, eteint);
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
}
void loop(){}