Build Your Own Arcade Controls Forum

Main => Main Forum => Topic started by: mrmalarkey on June 04, 2020, 04:24:50 am

Title: Using a piezo sensor with IPAC Keyboard encoder.
Post by: mrmalarkey on June 04, 2020, 04:24:50 am
Hi there,

Just wondering if it is possible to use a piezo sensor with a keyboard encoder, and if so, whether I would have to do anything special to make it work?

Kind regards,

Mr Malarkey
Title: Re: Using a piezo sensor with IPAC Keyboard encoder.
Post by: PL1 on June 04, 2020, 07:05:37 am
Just wondering if it is possible to use a piezo sensor with a keyboard encoder, and if so, whether I would have to do anything special to make it work?
It won't work directly with an "active low" (ground applied to input triggers the output) keyboard encoder.
- AFAIK a piezo sensor at rest with no load will generate no voltage which is the opposite of what you need.   :banghead:

The video on this (https://www.sparkfun.com/products/10293) Sparkfun Piezo sensor page shows it controlling an LED connected to an Arduino.
- The LED output is triggered by knocking or tapping on the sensor.

https://www.youtube.com/watch?v=e5zuGxIGj_A

The code for that Knock sketch (https://www.arduino.cc/en/Tutorial/Knock) uses the "analogRead()" command so you'll need an Arduino with analog inputs like the Pro Micro.

There's info about how to adjust the sensitivity from 4:35-6:02 in this video.

https://www.youtube.com/watch?v=sqHJ9tDC9IM

You might be able to make the Knock sketch invert the LED state by changing line 33 from . . .
Code: [Select]
int ledState = LOW;         // variable used to store the last LED status, to toggle the light. . . to . . .
Code: [Select]
int ledState = HIGH;         // variable used to store the last LED status, to toggle the light
That change should make the LED stay on until you knock or press the sensor.

If that works, hook the Arduino LED output to your active low keyboard encoder input.
- LED on (logic high) = same as button not pressed.
- LED off (logic low) = same as button pressed.

There may be a better way, but this should get you started.   :cheers:


Scott