0

Piezoelectric knock sensor
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Piezoelectric knock sensor

by Walter_doesnt_know on Thu Apr 08, 2021 11:41 pm

I want to use a this piezoelectric element ( https://www.adafruit.com/product/1739 ) as a knock sensor with a Circuitplayground express, but I am having trouble finding anything on the subject. I need to know how to hook it up and how to code it (so sorry for my complete noobness). Ultimately, my goal is to have the CPX change the text displayed on a TFT gizmo. I already have the TFT gizmo text working pretty well. Thanks for anything you can do!

Walter_doesnt_know
 
Posts: 1
Joined: Thu Apr 08, 2021 11:21 pm

Re: Piezoelectric knock sensor

by mikeysklar on Fri Apr 09, 2021 5:58 pm

You have the hardware built into the CPX for easy "tap" detection (accelerometer) if you wanted to start with a trivial example and build up from there.

Code: Select all | TOGGLE FULL SIZE
# Circuit Playground Express Tap Detect
#
# Author: Carter Nelson
# MIT License (https://opensource.org/licenses/MIT)
from adafruit_circuitplayground.express import cpx

# Configure double tap detection
cpx.detect_taps = 2

# Loop forever
while True:
    if cpx.tapped:
        print("TAP!")


https://learn.adafruit.com/circuit-play ... p-detect-2

We do have an older guide on knock detection using a piezo buzzer which is more involved, but you could take a look at the schematic to get an idea of what is going on there.

https://learn.adafruit.com/secret-knock ... ock/wiring

mikeysklar
 
Posts: 4634
Joined: Mon Aug 01, 2016 8:10 pm

Please be positive and constructive with your questions and comments.