BGONZA200

HiI am currently trying to build a drumkit that triggers sounds in pro tools. i have got it working using buttons. However I am now trying to find a way to replace the button with a piezo. Any help with this would be very apreciated.

BGONZA200

BGONZA200

Hi againThanks for the links, i am still really struggling to work out how to replace the code that uses the button to trigger pro tools with the piezo. I have connected the piezo and connected it the same as this link you kindly supplied. http://www.arduino.cc/en/Tutorial/KnockSensor. I have it working so that the light goes bright when you tap the piezo, and i am able to monitor the values that are triggered from the piezo via the monitor window. The main thing i am struggling with now is, how do i change the code so that the piezo signal replaces the button. Any advice in regard to this would be a great help. I have been reading up on the code as well as following the tutorials and have no idea what to try now.

The main difference is the piezo returns an analog value instead of a digital, so you will need to deal with values that are 0-1023 rather than HIGH/LOW.

One approch may be to use a threshold value (x) that over which you treat it as HIGH and below which it is LOW. That means you can reduce the number of changes to your current code.

Alternatively, you can use the additional information from a piezo to include 'loudness' of the drum. In this case you could use the value 0-1023 as an indication of how hard the drum is hit and, therefore, how loud it would be.

I would suggest you experiment with one piezo and the serial monitor, printing the values, to get a feel for what hitting the piezo does.

A couple of other suggestions:* Your code has a lot of repetition in it. This means that you should be able to define a functin to do one drum (passing in the right parameters) and then call it with different parameters to do the other drums. This will make maintaining the code easier (eg, to change the way all drums work you only need to change the one function).* Consider using arrays to store repetitive data and implify processing your code (see below for an example)From

Get the idea? You can do the same with the drum notes. The you can go through the whole lot using a 'for' loop in a few statements, as long as the array indices (ie, the 0, 1, etc) for the arrays are congruent for all arrays.