Conversation

per1234

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.


Originally reported at arduino/docs-content#2159

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.
@per1234per1234 added type: imperfectionPerceived defect in any part of projectRelated to content of the project itselflabels Sep 11, 2024
@per1234per1234 self-assigned this Sep 11, 2024
@per1234per1234 merged commit 00b6086 into arduino:main Sep 11, 2024
17 checks passed
@per1234per1234 deleted the knock-delay-position branch September 11, 2024 11:43
Sign up for free to join this conversation on . Already have an account? Sign in to comment
topic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project
None yet

Successfully merging this pull request may close these issues.

@per1234