Piezo sensors and Arduino

Lorenzo Sattin's icon

Hi guys,

i'm developing a project based on an interactive drum machine with piezo sensor;
these sensors help me to detect the shot and they're placed between a piece of wood and an elastic rubber.

I'd already made the patch to communicate Arduino and Max, in fact I receive some number from 0 to 1024.
On my max/msp patch i need to detect the variations of value from 0 to shot (ex. 900) omitting all release values but paying attention to a new shot.
So, I need all the positive changes from the sensors and not the negative ones.

Thank you all.

Rodrigo's icon

What it seems like you what is a threshold/gate. For this kind of usage (trigger) you want a schmitt trigger. This will trigger once you go ABOVE the threshold, but it wont trigger again until you go BELOW another threshold. This removes a lot of false triggers.

Max Patch
Copy patch and select New From Clipboard in Max.

If you're in the signal domain thresh~ does this automatically. But in the Max domain the following patch is handy:

brendan mccloskey's icon

[past] is also useful, in the Max domain but with a 'fixed' threshold. Rodrigo is the drum-ist expert though! Are you using off-the-shelf piezos? You can easily build noise-cancelling piezos, as a pair with common ground and TRS jack, FWIW.