You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Arduino switch and button library for SPST, SPDT or SP3T contacts. Simple to use, provides debouncing, deglitching and uses very little memory. Status indicates one-shot transitions (depicting direction) and current position status.
5
8
@@ -12,6 +15,8 @@ Arduino switch and button library for SPST, SPDT or SP3T contacts. Simple to use
12
15
13
16
## Using Toggle
14
17
18
+
Simple to use because pinMode, input pullups, de-glitch period, bounce period, and switch type (1 or 2 inputs) is automatically detected and configured.
19
+
15
20
Declaring a switch or button using 1 digital pin for SPST or SPDT contacts:
16
21
17
22
```c++
@@ -24,7 +29,7 @@ Declaring a switch or button using 2 digital pins for SP3T contacts:
24
29
Toggle sw2(7, 8); // GPIO 7 and 8
25
30
```
26
31
27
-
The library sets the pin in input mode with pull-up resistor enabled. All switches have to be polled in the `loop()` function.
32
+
Each switch is polled in the `loop()` function:
28
33
29
34
```c++
30
35
sw1.poll();
@@ -97,14 +102,22 @@ void loop() {
97
102
98
103
Switching between GND and digital pin is the default solution used by this library. External pull-up resistors can be added if desired, but the internal pullups should be sufficient for most applications. What might be of consideration is providing sufficient wetting current to overcome switch contact oxidation.
99
104
100
-
A set of connections are shown where 0.1μF capacitors are added to provide the following benefits:
105
+
A set of connections are shown where 0.1μF capacitors are optionally added to provide the following benefits:
101
106
102
107
- contact wetting current
103
108
- hardware signal filtering
104
109
- beneficial for interrupt applications
105
110
- improves noise immunity when using longer cables
106
111
107
-
Connections shown below are for 3-position switches, both without and with capacitors installed. Note: Connections for basic SPST or SPDT buttons or switches requiring only 1 input are similar and not shown.
112
+
#### Connections shown below are for 2-position switches (SPST, SPDT, DPDT) using 1 input:
0 commit comments