-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new functions to set and get the timer mode. Now the timer can start onPress, onRelease or onChange events. New retrigger on press example added.
- Loading branch information
Showing
7 changed files
with
250 additions
and
146 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
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,39 @@ | ||
/************************************************************************** | ||
Retrigger On Press Example: | ||
=========================== | ||
An example that shows how to retrigger an event while a button is pressed. | ||
The retrigger period (ms) determines the rate. Each expired time period is | ||
counted and displayed on the serial monitor. The built in LED toggles on | ||
each trigger event. | ||
*************************************************************************/ | ||
|
||
#include <Toggle.h> | ||
|
||
const byte buttonPin = 2; | ||
const word retriggerMs = 200; | ||
const byte ledPin = LED_BUILTIN; | ||
bool ledState = false; | ||
byte trigCount = 0; | ||
|
||
Toggle sw1(buttonPin); | ||
|
||
void setup() { | ||
while (!Serial) { }; // Leonardo | ||
Serial.begin(115200); | ||
pinMode(ledPin, OUTPUT); | ||
sw1.begin(buttonPin); | ||
} | ||
|
||
void loop() { | ||
sw1.poll(); | ||
if (sw1.retrigger(retriggerMs)) { | ||
trigCount++; | ||
Serial.println(trigCount); | ||
ledState = !ledState; | ||
digitalWrite(ledPin, ledState); | ||
} | ||
if (sw1.onRelease()) { | ||
Serial.println(F("Released")); | ||
trigCount = 0; | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name=Toggle | ||
version=3.0.1 | ||
version=3.0.2 | ||
author=David Lloyd | ||
maintainer=David Lloyd <[email protected]> | ||
sentence=Arduino bounce library for deglitching and debouncing hardware, signals and data. Works with all switch types, port expander and other 8-bit data sources. | ||
|
Oops, something went wrong.