Hello everybody !
I'm currently into a really cool project which gives me quite hard times. To begin, I'm a big noob in electronics, but I'm decent in programming. So i'm able to understand, learn or correct myself easily when it's about code, but I'm really in the dark for everything concerning electronics despite the fact that I read so much about it recently...
My projet
My goal is to make my own MIDI drum kit. Not a new idea, but the difference is that I want to use lot of pads. I bought some WII, XBOX and PS drum kits that I disassembled to get just de pads.
Then I bought an Arduino Uno, not a mega because I'm a beginner and I can totally start with a small amount of pads, also I wanted the perfect solution in terms of compatibility etc.
STEP ONE : 1 pad
So, I first made a prototype with 1 pad, which was very easy to do, since there is billion of officials and unofficials tutorials about how to connect a piezo to the Arduino. So basically, on my breadboard its like that (except im on A0 not A2) :
So I connected my pad to the Arduino with a 1 Mohm resistor in parallel and I made a program which function very very well. You can read it the :
// Standard MIDI library for Arduino
#include <MIDI.h>
#include <midi_Defs.h>
#include <midi_Message.h>
#include <midi_Namespace.h>
#include <midi_Settings.h>
// Variables
const int ledPin = 13; // control LED
const int knockSensor = A0; // First analog in pin
const int threshold = 250; // threshold of 250 is hard enough so it's stable, but soft enough so you dont have to hit hard
int sensorReading = 0;
MIDI_CREATE_DEFAULT_INSTANCE();
// Here I setup the test LED on digital pin 13, start the MIDI engine and start the serial connection
// so I can send both verification strings and MIDI information to the computer
void setup() {
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
MIDI.begin();
Serial.begin(115200); // this value of 115200 is for the serial to be understood by Hairless serial to MIDI convertor
// so when I hit the pad, it plays sounds in Ableton, Maschine, whatever I want
}
void loop() {
sensorReading = analogRead(knockSensor); // I read the piezo hit
if(sensorReading >= threshold) // If its above the treshold
{
int nouValeur = map(sensorReading, 0, 1023, 0, 127); // mapping hit value to MIDI velocity value to send proper MIDI info
digitalWrite(ledPin, HIGH); // light the LED
MIDI.sendNoteOn(42,nouValeur,1); // send a note
delay(10);
digitalWrite(ledPin, LOW); // shut the light
MIDI.sendNoteOff(42,nouValeur,1); // shut the note send
}
}
The only challenge here was to set proper threshold and delay so the signal is clean when I hit the pad with a drumstick, to integrate the MIDI library and finally to find a software that makes the informations i send available in any of my favourites music softwares (Ableton Live, Maschine, ...), this software is Hairless Serial to MIDI, btw.
STEP TWO : X pads
It's when I'm getting troubles.
At first I believed that all I needed to do was to reproduce the same schematic but "duplicate it" x times. So I tried with 4 pads. I used the same strategy on my breadboard : each pad is connected in parallel with a 1 M ohm resistor, but all are connected to ground. You can see it there :

The code, take the old one, but just loop on the 4 pins :
#include <MIDI.h>
#include <midi_Defs.h>
#include <midi_Message.h>
#include <midi_Namespace.h>
#include <midi_Settings.h>
const int ledPin = 13;
int myToms[] = {14,15,16,17 }; // On Arduino UNO, digital pin AO = 14, A1 = 15, etc.
int laNote[] = { 60,61,62,63 }; // Do, Do#, Re, Re#
const int threshold = 250;
int sensorReading = 0;
MIDI_CREATE_DEFAULT_INSTANCE();
void setup() {
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
MIDI.begin();
Serial.begin(115200);
}
void loop() {
for(int i=0; i<4; i++) // For each of the digital input
{
sensorReading = analogRead(myToms[i]); // we store it into the variable
if(sensorReading >= threshold)
{
int nouValeur = map(sensorReading, 0, 1023, 0, 127);
digitalWrite(ledPin, HIGH);
MIDI.sendNoteOn(laNote[i],nouValeur,1);
delay(10);
digitalWrite(ledPin, LOW);
MIDI.sendNoteOff(laNote[i],nouValeur,1);
}
}
}
So here are the 2 issues :
-
The pad on the left is OK, like with my 1st program, the second one is still ok, the third one I have to hit a bit hard, the fourth one I have to hit VERY hard.
-
When I hit a pad, it seems it send electricity in others pins, I say that because when i connect the Arduino to a music software, hiting a pad = having multiples notes at the same time.
For the hitting force issue, I'vre tried to play with resistances, puting higher or lower values and I got totally lost with that : nothing seemed to be better. About that "leaking" issue, I thought it could be useful to put some diodes, as i heard diodes are usefull when you want to make the current going in one way only, but when i watch some others schematics, i see no diodes and only 1 Mohms resistors everywhere, so I really don't know what is wrong and what to do.
Here is the MIDI xylophone someone made and posted on instructables : http://cdn.instructables.com/FB6/VMRG/H4AGICO1/FB6VMRGH4AGICO1.LARGE.jpg
I have no idea why this is working and why there is ground directly linked to these analog pins, and many other things i cannot understand.
Any help would be really appreciated ! ![]()

