-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fixed toggle function - Added `begin()` function to setup in examples - Updated readme
- Loading branch information
Showing
13 changed files
with
47 additions
and
42 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
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
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,32 +1,38 @@ | ||
/************************************************************************ | ||
/****************************************************************** | ||
One Button and One Three Position Switch: | ||
========================================= | ||
This example checks each time a button or 3-position switch | ||
This example that blinks an LED each time the button | ||
has transitioned. All input pins will have their pullups enabled. | ||
Open the Serial Monitor to view transition status. | ||
***********************************************************************/ | ||
*****************************************************************/ | ||
|
||
#include <Toggle.h> | ||
|
||
const byte buttonPin = 2; | ||
const byte swPinA = 3; | ||
const byte swPinB = 4; | ||
const byte ledPin = LED_BUILTIN; | ||
|
||
Toggle sw1(buttonPin); // button | ||
Toggle sw2(swPinA, swPinB); // 3-position switch | ||
|
||
void setup() { | ||
pinMode(ledPin, OUTPUT); | ||
while (!Serial) { }; // Leonardo | ||
Serial.begin(115200); | ||
sw1.begin(buttonPin); | ||
sw2.begin(swPinA, swPinB); | ||
} | ||
|
||
void loop() { | ||
sw1.poll(); | ||
sw2.poll(); | ||
|
||
if (sw1.onPress()) Serial.println(F("sw1: OFF⇒ON")); | ||
if (sw1.onRelease()) Serial.println(F("sw1: ON⇒OFF")); | ||
if (sw2.UPtoMID()) Serial.println(F("sw2: UP⇒MID")); | ||
if (sw2.MIDtoDN()) Serial.println(F("sw2: MID⇒DN")); | ||
if (sw2.DNtoMID()) Serial.println(F("sw2: DN⇒MID")); | ||
if (sw2.MIDtoUP()) Serial.println(F("sw2: MID⇒UP")); | ||
digitalWrite(ledPin, sw1.toggle()); | ||
} |
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,33 +1,32 @@ | ||
/************************************************************************ | ||
/*********************************************************************** | ||
Using Three Position Switches: | ||
============================== | ||
A simple example that toggles an LED each time a 3-position switch has | ||
transitioned. Both input pins will have its pullup enabled. The | ||
switch is in the disconnected MID position if both inpits read high. | ||
• open Serial Monitor to view transition status. | ||
***********************************************************************/ | ||
Open the Serial Monitor to view transition status. | ||
**********************************************************************/ | ||
|
||
#include <Toggle.h> | ||
|
||
const byte pinA = 2; | ||
const byte pinB = 3; | ||
const byte ledPin = LED_BUILTIN; | ||
|
||
Toggle sw1(pinA, pinB); // 3-position switch | ||
Toggle sw1(pinA, pinB); // 3-position switch | ||
|
||
void setup() { | ||
pinMode(ledPin, OUTPUT); | ||
while (!Serial) { }; // Leonardo | ||
Serial.begin(115200); | ||
sw1.begin(pinA, pinB); | ||
} | ||
|
||
void loop() { | ||
sw1.poll(); | ||
// call toggle() just after poll(). Toggles on MID⇒UP transitions only | ||
digitalWrite(ledPin, sw1.toggle()); | ||
|
||
if (sw1.UPtoMID()) Serial.println(F("sw1: UP⇒MID")); | ||
if (sw1.MIDtoDN()) Serial.println(F("sw1: MID⇒DN")); | ||
if (sw1.DNtoMID()) Serial.println(F("sw1: DN⇒MID")); | ||
if (sw1.MIDtoUP()) Serial.println(F("sw1: MID⇒UP")); | ||
digitalWrite(ledPin, sw1.toggle()); // toggles on MID⇒UP transition only | ||
} |
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.0 | ||
version=3.0.1 | ||
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. | ||
|
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