I’ve been working on making an electric drum controller using my Arduino Duemilanove and have run into some problems. I started with the Spikenzie Labs Drum Kit Kit sketch (will post link in reply), but found that I was getting triggering across pins. I had my drum trigger connected to pin 0, but was getting triggering as though there were triggers connected to the other analog pins as well. I’m using TTYMidi in Linux, and when running it in verbose mode I can see that the output from the Arduino has multiple triggers on multiple MIDI notes. The sketch uses for(pin = 0, pin < 6, pin++) to associate the analogRead signals from each analog pin to a specific midi instrument. If I change it to pin < 1, it works fine. I thought maybe there was some interference since the sketch also waits to trigger on a pin until a specified time, and thought that incoming signals could just be interpreted as another pin. I isolated each pin, even isolated the variables, but no matter what if I have two pins defined in the sketch, a trigger on either pin will send a MIDI signal for both. I have tried various baud rates (adjusting TTYMidi accordingly) but still get the same problem. I’m a novice programmer, but the only other possibility I can think of is that there is some quirk to the MIDI library that might be causing this. My linux machine isn’t networked, but I’ll paste a copy of the sketch in (it’s really basic) when I get it online. Any suggestions would be appreciated.
Are you using piezos as the drum pad triggers ?
If so, are you sure that the piezoes are physically isolated from each other, so that hitting one of them doesen't accidently trigger one or more of the others ?
I had that problem once (on a non Arduino based prject) and it took quite some experimenting with various layers of foam and stuff to isolate the piezoes from each other.
Are you allowing sufficient time for the analog pins to stabilize after reading each one? To get valid results, there needs to be a small delay (a few microseconds) to allow the ADC to stabilize.
I am using piezos and they are completely isolated in separate drums. I've even tried running it with only one trigger attached and I still get the same results.
The sketch includes a timer after a hit is registered before another hit can be registered on a pin. I've tried it up to 60ms and get the same result. I'll try increasing the time more to see if that makes a difference, but I'm worried that if I go too much higher it will affect the playability.
I raised it to 100ms and I’m getting exactly two Midi messages for each hit, one for each pin. I’ve tried changing the pin number as well, but no matter which pin I use it’s registering a hit on all pins (I have been using only 2 while trying to troubleshoot, but it occurs for all 6 if I have them all active).
Are any of your analog pins left floating ?
This can sometimes lead to problems like those you describe.
It was a floating pin. I have a resistor and a zehner diode going from my active pin to ground on the piezo circuit, but didn't realize I needed something on a pin that had no input. Thanks for helping me learn something.
Sorry if this is an obvious question, but what is a floating pin?
Should all non used analog pins be connected with the resistor and zener diode?
From how I understand it, a floating pin is one where values are expected but that isn't grounded.
You would only need something if your sketch is expecting input on that pin. Just a 1M Ohm resistor or so from the pin to ground resolved my issue.