Project

General

Profile

Digital Input » History » Version 3

Adam Klama, 06/21/2026 03:11 PM

1 1 Adam Klama
# Digital Input
2
3
## Overview
4
A **Digital Input** reads an on/off (digital) state on a hardware pin — a switch,
5
button or relay contact. The input is **on** when the pin is **shorted to signal
6
ground (sGND)** and **off** when it is open. On reads as **1024**, off as **0**
7
(use **Invert** to swap them). In its other modes the same pin can instead measure
8
a property of a digital waveform: its duty cycle, frequency, or pulse time.
9
10
Use it for door/neutral switches, mode buttons, and simple signals you only need a
11
single value from. For richer frequency/speed/position work, prefer the
12 2 Adam Klama
[Frequency Input](Frequency_Input).
13 1 Adam Klama
14
## Prerequisites & hardware
15
- A contact or signal that **shorts the pin to sGND** to signal "on", and leaves it
16
  open for "off".
17
- On = `1024`, off = `0`; use **Invert** if your wiring is the other way round.
18
- Mechanical contacts bounce; plan to use the **debounce** timings below.
19
- For Duty/Frequency/Time modes the signal must be a clean repeating waveform.
20
21
## Add it in the app
22
1. Add a new input and choose **Digital Input** as the type.
23
2. Select the **pin** the signal is wired to.
24
3. Give it a clear **alias** (e.g. `Neutral Switch`).
25
4. Choose the **mode** (plain on/off, or duty / frequency / time).
26
5. Set **Invert** and the **debounce** timings as needed.
27
28
## Settings reference
29
30
| Setting | Meaning | Unit | Range / values | Notes |
31
|---|---|---|---|---|
32
| **Mode** | What the pin reads | — | `Digital In`, `Duty`, `Frequency`, `Time` | `Digital In` = plain on/off. The other modes measure that property of a digital waveform on the same pin. |
33
| **Invert** | Swaps on/off (`1024` ↔ `0`) | — | on / off | By default on = pin shorted to sGND. Invert if the active state is the open one. |
34
| **Enable filter** | Turns on debounce filtering | — | on / off | Recommended for mechanical switches. The three timings below apply when on. |
35
| **Delay** | Debounce delay before a state change is accepted | ms | sint32 | A new level must be stable for this long before it is reported. |
36
| **Hold** | Minimum time a state is held once accepted | ms | sint32 | Stops rapid re-triggering; the state is kept at least this long. |
37
| **Interspace** | Minimum gap between transitions | ms | sint32 | Ignores transitions that arrive closer together than this. |
38
39
**Debounce:** **Delay**, **Hold** and **Interspace** work together to reject
40
contact bounce and electrical noise. Start with small values (a few ms) and
41
increase only if you still see false toggles.
42
43
## Common settings
44
Digital Input also uses the shared settings — alias and pin. See
45 2 Adam Klama
[Common IO Settings](Common_IO_Settings).
46 1 Adam Klama
47
## Example — neutral switch
48
1. Type **Digital Input**, alias `Neutral Switch`, on the switch's pin.
49
2. Mode `Digital In`.
50
3. The switch closes to sGND in neutral, so it reads **on (1024)** in neutral
51
   directly — no invert needed (turn **Invert on** only if your wiring is opposite).
52
4. **Enable filter**, set **Delay** `20`, **Hold** `30`, **Interspace** `10` to
53
   reject contact bounce.
54
55
## Troubleshooting
56
- **State flickers / chatters:** enable the filter and raise **Delay** /
57
  **Interspace**.
58
- **Reads the opposite of what you expect:** toggle **Invert**.
59
- **Change is missed or too slow:** **Delay** is too high — lower it.
60
- **Duty/Frequency/Time reads zero:** confirm the mode matches the signal and that
61
  the waveform actually toggles cleanly on that pin.
62
63
## Related
64 2 Adam Klama
- [Frequency Input](Frequency_Input) — frequency, speed, duty or pulse time.
65
- [Analog Switch Input](Analog_Switch_Input) — multi-position switch on one
66 1 Adam Klama
  analog pin.
67 2 Adam Klama
- [Counter Input](Counter_Input) — count events/edges.