-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit 7f75d46
Only delay after serial output in "Knock"
The "Knock" sketch polls the voltage output from a piezo disc to detect the vibrations associated with a knock.
The duration of vibrations from a single knock is likely to significantly exceed the unchecked polling interval. This
would result in a single knock producing multiple detections, and thus multiple prints to Serial. In order to avoid
this, a "debouncing" delay was added to the sketch.
Previously the delay was positioned in the outer scope of the `loop` function, which caused it to always affect the
polling interval. This caused the sketch to miss the detection of knocks that produced vibrations that only occurred
during that unnecessary delay. The problem is fixed by moving the delay inside the knock detection conditional block, so
that debouncing is only done when actually needed.1 parent f1abc30 commit 7f75d46
1 file changed
+1
-1
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
49 | 49 |
| |
50 | 50 |
| |
51 | 51 |
| |
52 | + | ||
52 | 53 |
| |
53 | - | ||
54 | 54 |
|
0 commit comments