Debounce

1

Why Sensor Thresholds Need More Than One If Statement

4 minute

Many sensor features eventually become a condition:

if (value > threshold) {
    alarm = true;
}

This looks reasonable, but real devices usually need more.

Sensor values jitter. Environments drift. Samples hit spikes. User actions may stay near the boundary. With only one threshold, the device can bounce between triggered and not triggered.

A better model is:

raw value
-> filtered value
-> threshold check
-> hysteresis, debounce, confirmation
-> state machine
-> product action

The threshold is only one part of state detection.

Read More