I need help, I have a project for an electric drum, I'm using 27mm piezos, 1Momn resistors and 5.1V Diode Zener, and a Multiplexer, I'm having a problem with one of the pads, where I hit it and it returns the sound it, but with an extra sound from another pad, I've already changed the sensor, I've changed the Arduino channel, I also checked the position and it doesn't touch the other, I came to the conclusion that the problem is in the code, I'm using the MIDI.h library and Hello Drum, can anyone help me?
/*
EXAMPLE - MUX Sensing
With this sample code, you can make 16 single piezo pads with a 4067.
https://github.com/RyoKosaka/HelloDrum-arduino-Library
*/
/////////////////////////////// SETTING VALUE ///////////////////////////////////
//Determine the setting value.
//By changing the number in this array you can set sensitivity, threshold and so on.
#define Drum_map 0 //0-ADD2, 1-EZD2
byte Note[2][16] = {
/* _ Hihat tip
| _ Kick
| | _ Snare Open hit
| | | _ Snare SideStick
| | | | _ Tom1
| | | | | _ Tom2
| | | | | | _ Tom3
| | | | | | | _ Tom4
| | | | | | | | _ Extra1
| | | | | | | | | _ Extra2
| | | | | | | | | | _ Cym1
| | | | | | | | | | | _ Cym2
| | | | | | | | | | | | _ Cym3
| | | | | | | | | | | | | _ Cym4
| | | | | | | | | | | | | | _ Ride tip
| | | | | | | | | | | | | | | _ Ride bell
| | | | | | | | | | | | | | | | BANK */
{ 51, 36, 38, 42, 71, 69, 67, 65, 47, 96, 77, 79, 81, 89, 60, 61 }, // 0 - ADD2 MAP
{ 20, 36, 38, 37, 47, 48, 41, 43, 45, 1, 55, 49, 57, 52, 51, 53 } // 1 - EZD MAP
};
int PAD1[5] = {
100, //sensitivity
5, //threshold
20, //scan time
35,
Note[Drum_map][14]
};
int PAD2[5] = {
100, //sensitivity
5,
20,
35,
Note[Drum_map][5]
};
int PAD3[5] = {
100, //sensitivity
5,
20,
35,
Note[Drum_map][4]
};
int PAD4[5] = {
100, //sensitivity
5,
20,
35,
Note[Drum_map][12]
};
int PAD5[5] = {
100, //sensitivity
5,
20,
35,
Note[Drum_map][0]
};
int PAD6[5] = {
100, //sensitivity
5,
20,
35,
Note[Drum_map][6]
};
int PAD7[5] = {
100, //sensitivity
5,
20,
35,
Note[Drum_map][2]
};
int PAD8[5] = {
100, //sensitivity
5,
20,
35,
Note[Drum_map][11]
};
int PAD9[5] = {
100, //sensitivity
5,
20,
35,
Note[Drum_map][1]
};
/////////////////////////////////////////////////////////////////////////////////////
#include <hellodrum.h>
//Using MIDI Library. If you want to use USB-MIDI, comment out the next two lines.
#include <MIDI.h>
#include <USB-MIDI.h>
USBMIDI_CREATE_DEFAULT_INSTANCE();
//Uncomment the next two lines for using USB-MIDI with atmega32u4 or Teensy
//#include <USB-MIDI.h>
//USBMIDI_CREATE_DEFAULT_INSTANCE();
/*
Mux Breakout ----------- Arduino
S0 ------------------- 2
S1 ------------------- 3
S2 ------------------- 4
S2 ------------------- 5
Z -------------------- A0
*/
//Define MUX Pins
HelloDrumMUX_4067 mux(1, 2, 3, 4, 0); //D2, D3, D4, D5, A0
//or use two 4501s
//HelloDrumMUX_4051 mux1(2,3,4,0); //D2, D3, D4, A0
//HelloDrumMUX_4051 mux2(5,6,7,1); //D5, D6, D7, A1
//name your pad and define mux pin
HelloDrum pad1(12);
HelloDrum pad2(13);
HelloDrum pad3(14);
HelloDrum pad4(15);
HelloDrum pad5(7);
HelloDrum pad6(9);
HelloDrum pad7(10);
HelloDrum pad8(11);
HelloDrum pad9(8);
void setup() {
//If you use Hairless MIDI, you have to comment out the next line.
MIDI.begin(10);
//And uncomment the next two lines.
//MIDI.begin();
}
void loop() {
mux.scan();
//or use two 4501s
//mux1.scan();
//mux2.scan();
pad1.singlePiezoMUX(PAD1[0], PAD1[1], PAD1[2], PAD1[3]);
pad2.singlePiezoMUX(PAD2[0], PAD2[1], PAD2[2], PAD2[3]);
pad3.singlePiezoMUX(PAD3[0], PAD3[1], PAD3[2], PAD3[3]);
pad4.singlePiezoMUX(PAD4[0], PAD4[1], PAD4[2], PAD4[3]);
pad5.singlePiezoMUX(PAD5[0], PAD5[1], PAD5[2], PAD5[3]);
pad6.singlePiezoMUX(PAD6[0], PAD6[1], PAD6[2], PAD6[3]);
pad7.singlePiezoMUX(PAD7[0], PAD7[1], PAD7[2], PAD7[3]);
pad8.singlePiezoMUX(PAD8[0], PAD8[1], PAD8[2], PAD8[3]);
pad9.singlePiezoMUX(PAD9[0], PAD9[1], PAD9[2], PAD9[3]);
if (pad1.hit == true) {
MIDI.sendNoteOn(PAD1[4], pad1.velocity, 10); //(note, velocity, channel)
MIDI.sendNoteOff(PAD1[4], 0, 10);
}
if (pad2.hit == true) {
MIDI.sendNoteOn(PAD2[4], pad2.velocity, 10); //(note, velocity, channel)
MIDI.sendNoteOff(PAD2[4], 0, 10);
}
if (pad3.hit == true) {
MIDI.sendNoteOn(PAD3[4], pad3.velocity, 10); //(note, velocity, channel)
MIDI.sendNoteOff(PAD3[4], 0, 10);
}
if (pad4.hit == true) {
MIDI.sendNoteOn(PAD4[4], pad4.velocity, 10); //(note, velocity, channel)
MIDI.sendNoteOff(PAD4[4], 0, 10);
}
if (pad5.hit == true) {
MIDI.sendNoteOn(PAD5[4], pad5.velocity, 10); //(note, velocity, channel)
MIDI.sendNoteOff(PAD5[4], 0, 10);
}
if (pad6.hit == true) {
MIDI.sendNoteOn(PAD6[4], pad6.velocity, 10); //(note, velocity, channel)
MIDI.sendNoteOff(PAD6[4], 0, 10);
}
if (pad7.hit == true) {
MIDI.sendNoteOn(PAD7[4], pad7.velocity, 10); //(note, velocity, channel)
MIDI.sendNoteOff(PAD7[4], 0, 10);
}
if (pad8.hit == true) {
MIDI.sendNoteOn(PAD8[4], pad8.velocity, 10); //(note, velocity, channel)
MIDI.sendNoteOff(PAD8[4], 0, 10);
}
if (pad9.hit == true) {
MIDI.sendNoteOn(PAD9[4], pad9.velocity, 10); //(note, velocity, channel)
MIDI.sendNoteOff(PAD9[4], 0, 10);
}
}