-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from elC0mpa/master
Interrupts support
- Loading branch information
Showing
3 changed files
with
97 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
Name: MultipleButtons.ino | ||
Created: 8/11/2019 11:45:52 AM | ||
Author: José Gabriel Companioni Benítez (https://github.com/elC0mpa) | ||
Description: Example to demostrate how to use the library with more than one button | ||
*/ | ||
|
||
#include <Arduino.h> | ||
#include <EasyButton.h> | ||
|
||
#define BUTTON_PIN 2 | ||
#define BAUDRATE 9600 | ||
|
||
EasyButton button(BUTTON_PIN); | ||
|
||
|
||
void buttonPressed() | ||
{ | ||
Serial.println("Button is pressed"); | ||
} | ||
|
||
void buttonPressedTwoSeconds() | ||
{ | ||
Serial.println("Button pressed for two seconds"); | ||
} | ||
|
||
void buttonSequence() | ||
{ | ||
Serial.println("Sequence"); | ||
} | ||
|
||
void buttonPressedReleased() | ||
{ | ||
button.read(); | ||
} | ||
|
||
void setup() { | ||
// put your setup code here, to run once: | ||
Serial.begin(BAUDRATE); | ||
button.begin(); | ||
if (button.supportsInterrupt()) | ||
{ | ||
Serial.println("Button will be used through external interrupts"); | ||
button.enableInterrupt(buttonPressedReleased); | ||
} | ||
|
||
button.onPressed(buttonPressed); | ||
button.onPressedFor(2000, buttonPressedTwoSeconds); | ||
button.onSequence(3, 5000, buttonSequence); | ||
} | ||
|
||
void loop() { | ||
// put your main code here, to run repeatedly: | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters