Skip to content

Commit

Permalink
See change notes in README
Browse files Browse the repository at this point in the history
  • Loading branch information
EasyG0ing1 committed Aug 20, 2022
1 parent 34e18a8 commit 17f9746
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 8 deletions.
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ This library enables you to create non-blocking timers using simple, common sens
* [Return Values on Stopped Timers](#return-values-on-stopped-timers)
* [Summary](#summary)
* [Examples](#examples)
* [BlockNotBlink](#blocknotblink)
* [BlockNotBlinkParty](#blocknotblinkparty)
* [DurationTrigger](#durationtrigger)
* [OnWithOffTimers](#onwithofftimers)
* [ResetAll](#resetall)
* [TimersRules](#timersrules)
* [BlockNot Blink](#blocknotblink)
* [BlockNot Blink Party](#blocknotblinkparty)
* [Button Debounce](#buttondebounce)
* [Duration Trigger](#durationtrigger)
* [On With Off Timers](#onwithofftimers)
* [Reset All](#resetall)
* [Timer's Rules](#timersrules)
* [Library](#library)
* [Methods](#methods)
* [Macros](#macros)
Expand Down Expand Up @@ -510,7 +511,7 @@ There are more methods that allow you to affect change on your timers after inst
# Examples
There are currently seven examples in the library.
There are currently eight examples in the library.
### BlockNotBlink
Expand All @@ -522,6 +523,10 @@ If you have a nano or an uno or equivalent laying around and four LEDs and some
**Non-Blocking MATTERS!**
### ButtonDebounce
Learn how to debounce a button without using delay()
### DurationTrigger
Read the section above to get an idea of what TRIGGERED_ON_DURATION does, then load this example up and play around
Expand Down Expand Up @@ -557,6 +562,8 @@ stopAfterThreeTimer. When you look at the number of milliseconds in each of the
outputs, you can see that indeed it does trigger three seconds after being reset,
but then it does not re-trigger until after it is reset again.
- Thanks to [@SteveRMann](https://github.com/SteveRMann) for kick-starting this example and working with me on fine-tuning it.
### MillisRolloverTest
Expand Down
38 changes: 38 additions & 0 deletions examples/ButtonDebounce/ButtonDebounce.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <BlockNot.h>

/**
* BlockNot can be used to debounce a button, and you don't even have to be conservative on your delay time
* because when you press a button, the odds that you'll press a button again within a single second even
* is really low, and since timers trigger AFTER the stated duration has passed, you can have your button
* code run only if the timer has triggered, which means that if it has triggered your code will run immediately
* without needing to debounce it using the delay() method, and after you let go of the button, the timer will
* be primed and ready to go very shortly there after. So then the duration of the timer can be as long as
* half a second or even a full second or longer since the timer is primed after that duration has already
* passed. You're basically debouncing ahead of time so that your button code can run immediately.
*
* Connect one pin of your button to pin 12 of your Arduino, then the other button pin goes to ground, then
* upload this sketch and try it out.
*
* If you want the button to respond faster than one second, change the timers duration from 1, SECONDS to
* something smaller like just 500 for half a second or 250 for 1/4 second.
*/

BlockNot buttonTimer(1, SECONDS);
//BlockNot buttonTimer(500); // 1/2 second
//BlockNot buttonTimer(250); // 1/4 second

#define BUTTON 12

#define BUTTON_PRESSED digitalRead(BUTTON) == LOW;


void setup() {
Serial.begin(115200);
pinMode(BUTTON, INPUT_PULLUP);
}

loop() {
if(BUTTON_PRESSED)
if(buttonTimer.TRIGGERED)
Serial.println("Button Pressed!");
}
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=BlockNot
version=2.0.3
version=2.0.4
author=Michael Sims <[email protected]>
maintainer=Michael Sims <[email protected]>
sentence=BlockNot gives you non-blocking timers with simplicity.
Expand Down

0 comments on commit 17f9746

Please sign in to comment.