From 1fc2971688b29be459c7327c5c62ca97943f9355 Mon Sep 17 00:00:00 2001 From: Armin Date: Mon, 25 Mar 2019 12:46:39 +0100 Subject: [PATCH] Added attachInterrupt() code --- README.md | 5 ++--- examples/OneButton/OneButton.ino | 3 +-- library.properties | 8 ++++---- src/EasyButtonAtInt01.h | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 0b30f85..341a4a0 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # EasyButton -Arduino library for handling push buttons at INT0 and / or INT1 pin (pin 2 / 3).
-The library is totally based on interrupt.
-Debouncing is implemented in a not blocking way! It is merely done by ignoring a button change within the debouncing time. +Arduino library for handling push buttons connected between ground and INT0 and / or INT1 pin (pin 2 / 3).
+The library is totally based on interrupt and debouncing is implemented in a not blocking way. It is merely done by ignoring a button change within the debouncing time. [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![Build Status](https://travis-ci.org/ArminJo/EasyButtonAtInt01.svg?branch=master)](https://travis-ci.org/ArminJo/EasyButtonAtInt01) diff --git a/examples/OneButton/OneButton.ino b/examples/OneButton/OneButton.ino index b59cb3b..eb13b9f 100644 --- a/examples/OneButton/OneButton.ino +++ b/examples/OneButton/OneButton.ino @@ -34,13 +34,12 @@ EasyButton Button0AtPin2(true); void setup() { // initialize the digital pin as an output. - pinMode(LED_BUILTIN, OUTPUT); +// pinMode(LED_BUILTIN, OUTPUT); // not needed here, since it is done by button library Serial.begin(115200); while (!Serial) ; //delay for Leonardo // Just to know which program is running on my Arduino Serial.println(F("START " __FILE__ "\r\nVersion " VERSION_EXAMPLE " from " __DATE__)); - } void loop() { diff --git a/library.properties b/library.properties index 6602c06..5136e54 100644 --- a/library.properties +++ b/library.properties @@ -1,9 +1,9 @@ name=EasyButtonAtInt01 -version=1.0 +version=1.0.0 author=Armin Joachimsmeyer maintainer=Armin Joachimsmeyer -sentence=Arduino library for handling push buttons at INT0 and / or INT1 pin (pin 2 / 3) -paragraph=Just attach buttons to pin 2 or 3 of your Arduino - thats it. In you main program define a EasyButton and use ButtonStateIsActive or ButtonToggleState to determine your action. Or use a callback function called once on every button press. If timing does matter, 3 more variables are available: ButtonPressDurationMillis, ButtonLastChangeMillis and ButtonReleaseMillis. -category=Input +sentence=Small and easy to use Arduino library for using push buttons at INT0 and / or INT1 pin (pin 2 / 3) using interrupts.
No call of begin() or update() function needed. No blocking debouncing.

+paragraph=Just connect buttons between ground and pin 2 or 3 of your Arduino - thats it.

In you main program define an EasyButton and use ButtonStateIsActive or ButtonToggleState to determine your action.
Or use a callback function which will be called once on every button press.

Usage:
#define USE_BUTTON_0
#include "EasyButtonAtInt01.h"
EasyButton Button0AtPin2(true);

void setup() {}
void loop() {
...
digitalWrite(LED_BUILTIN, Button0AtPin2.ButtonToggleState);
...
}

If button timing is of interest, 3 variables are available: +category=Signal Input/Output url=https://github.com/ArminJo/EasyButtonAtInt01 architectures=avr diff --git a/src/EasyButtonAtInt01.h b/src/EasyButtonAtInt01.h index 0c3324b..f499aa9 100644 --- a/src/EasyButtonAtInt01.h +++ b/src/EasyButtonAtInt01.h @@ -1,7 +1,7 @@ /* * EasyButtonAtInt01.h * - * Arduino library for handling push buttons at INT0 and / or INT1 pin (pin 2 / 3). + * Arduino library for handling push buttons connected between ground and INT0 and / or INT1 pin (pin 2 / 3). * The library is totally based on interrupt. * Debouncing is implemented in a not blocking way! It is merely done by ignoring a button change within the debouncing time. *