Open attachi201 opened 4 years ago
Hi, did you fix the problem? Thanks
If there is nothing connected to the analog or MUX pins for sensing (floating pins), it will pick up noise and be perceived as a continuous hit. Connect a pad to all the pins, or if not, use a 1MΩ resistor to connect them to GND.
@RyoKosaka You're right, the code can now be used, thank you very much.
@jhsa Now it works. But you have to connect all pads to the board.
Can the MUX chips be daisy-chained or is it better/faster to have them run separately like in the poster's code?
Hi i use 31 pads but the flashing LCD shows SPLASH1. can't press any buttons, but when i comment code scan mux SENSING & SENDING MIDI So it works
i use Mega2560 with 4*MUX IC and EEPROM MUX LCDI2C code this is my code
`
include
include
include
LiquidCrystal_I2C lcd(0x27, 16, 2);
MIDI_CREATE_DEFAULT_INSTANCE();
/ Mux Breakout ----------- Arduino S0 ------------------- 2 S1 ------------------- 3 S2 ------------------- 4 Z -------------------- A0 / //Define MUX Pins
HelloDrumMUX_4051 mux1(2,3,4,0); //D2, D3, D4, A0
HelloDrumMUX_4051 mux2(5,6,7,1); //D5, D6, D7, A1
HelloDrumMUX_4051 mux3(8,9,10,2); //D8, D9, D10, A2
HelloDrumMUX_4051 mux4(11,12,13,3); //D11, D12, D13, A2
//Please name your pad and controller.
HelloDrum snare(0, 1); HelloDrum hihat(2, 3); HelloDrum ride(4, 5); HelloDrum kick1(6); HelloDrum kick2(7); HelloDrum tom1(8); HelloDrum rimtom1(9); HelloDrum tom2(10); HelloDrum rimtom2(11); HelloDrum tom3(12); HelloDrum rimtom3(13); HelloDrum tom4(14); HelloDrum rimtom4(15); HelloDrum tom5(16); HelloDrum rimtom5(17); HelloDrum crash1(18, 19); HelloDrum crash2(20, 21); HelloDrum crash3(22, 24); HelloDrum crash4(25, 26); HelloDrum china1(27); HelloDrum china2(28); HelloDrum splash1(29); HelloDrum splash2(30); HelloDrum hihatPedal(23);
//Set the DIGITAL pin number to which the buttons are connected. HelloDrumButton button(14, 15, 16, 17, 18); //(EDIT,UP,DOWN,NEXT,BACK)
void setup() { lcd.init(); // initialize the lcd lcd.backlight();
//if you use ESP32, you have to uncomment the next line. //EEPROM_ESP.begin(512);
//If you use Hairless MIDI, you have to comment out the next line. //MIDI.begin(10); //And uncomment the next two lines. Please set the baud rate of Hairless to 38400. MIDI.begin(); Serial.begin(38400);
//Give each pad a name to be displayed on the LCD. //It is necessary to make the order in exactly the same order as you named the pad first.
snare.settingName("SNARE"); hihat.settingName("HIHAT"); hihatPedal.settingName("HIHAT PEDAL"); ride.settingName("RIDE"); kick1.settingName("KICK1"); kick2.settingName("KICK2"); tom1.settingName("TOM1"); rimtom1.settingName("RIMTOM1"); tom2.settingName("TOM2"); rimtom2.settingName("RIMTOM2"); tom3.settingName("TOM3"); rimtom3.settingName("RIMTOM3"); tom4.settingName("TOM4"); rimtom4.settingName("RIMTOM4"); tom5.settingName("TOM5"); rimtom5.settingName("RIMTOM5"); crash1.settingName("CRASH1"); crash2.settingName("CRASH2"); crash3.settingName("CRASH3"); crash4.settingName("CRASH4"); china1.settingName("CHINA1"); china2.settingName("CHINA2"); splash1.settingName("SPLASH1"); splash2.settingName("SPLASH2");
//Load settings from EEPROM. //It is necessary to make the order in exactly the same order as you named the pad first.
snare.loadMemory(); hihat.loadMemory(); hihatPedal.loadMemory(); ride.loadMemory(); kick1.loadMemory(); kick2.loadMemory(); tom1.loadMemory(); rimtom1.loadMemory(); tom2.loadMemory(); rimtom2.loadMemory(); tom3.loadMemory(); rimtom3.loadMemory(); tom4.loadMemory(); rimtom4.loadMemory(); tom5.loadMemory(); rimtom5.loadMemory(); crash1.loadMemory(); crash2.loadMemory(); crash3.loadMemory(); crash4.loadMemory(); china1.loadMemory(); china2.loadMemory(); splash1.loadMemory(); splash2.loadMemory();
lcd.clear(); lcd.print("Hello world!"); lcd.setCursor(0, 1); lcd.print("Hello drum!"); }
void loop() {
/////////// 1. LCD and SETTING MODE /////////////
bool buttonPush = button.GetPushState(); bool editStart = button.GetEditState(); bool editDone = button.GetEditdoneState(); bool display = button.GetDisplayState();
char padName = button.GetPadName(); char item = button.GetSettingItem(); int settingValue = button.GetSettingValue(); int velocity = button.GetVelocity(); char *hitPad = button.GetHitPad();
button.readButtonState();
snare.settingEnable(); hihat.settingEnable(); hihatPedal.settingEnable(); ride.settingEnable(); kick1.settingEnable(); kick2.settingEnable(); tom1.settingEnable(); rimtom1.settingEnable(); tom2.settingEnable(); rimtom2.settingEnable(); tom3.settingEnable(); rimtom3.settingEnable(); tom4.settingEnable(); rimtom4.settingEnable(); tom5.settingEnable(); rimtom5.settingEnable(); crash1.settingEnable(); crash2.settingEnable(); crash3.settingEnable(); crash4.settingEnable(); china1.settingEnable(); china2.settingEnable(); splash1.settingEnable(); splash2.settingEnable();
if (buttonPush == true) { lcd.clear(); lcd.print(padName); lcd.setCursor(0, 1); lcd.print(item); lcd.setCursor(13, 1); lcd.print(settingValue); }
if (editStart == true) { lcd.clear(); lcd.print("EDIT START"); delay(500); lcd.clear(); lcd.print(padName); lcd.setCursor(0, 1); lcd.print(item); lcd.setCursor(13, 1); lcd.print(settingValue); }
if (editDone == true) { lcd.clear(); lcd.print("EDIT DONE"); delay(500); lcd.clear(); lcd.print(padName); lcd.setCursor(0, 1); lcd.print(item); lcd.setCursor(13, 1); lcd.print(settingValue); }
//show hitted pad name and velocity to LCD //Immediately after I2C communication, scanning of piezo is stop. //So if you change the display right after you hit pad, it affects the sensing. //I recommend leaving it as a comment.
////////// 2. SENSING & SENDING MIDI////////////
//Sensing each pad.
mux1.scan();
mux2.scan();
mux3.scan();
mux4.scan();
snare.dualPiezoMUX(); hihat.HH2zoneMUX();
hihatPedal.hihatControlMUX(); ride.cymbal3zoneMUX(); crash1.cymbal2zoneMUX(); crash2.cymbal2zoneMUX(); crash3.cymbal2zoneMUX(); crash4.cymbal2zoneMUX(); kick1.singlePiezoMUX(); kick2.singlePiezoMUX(); tom1.singlePiezoMUX(); rimtom1.singlePiezoMUX(); tom2.singlePiezoMUX(); rimtom2.singlePiezoMUX(); tom3.singlePiezoMUX(); rimtom3.singlePiezoMUX(); tom4.singlePiezoMUX(); rimtom4.singlePiezoMUX(); tom5.singlePiezoMUX(); rimtom5.singlePiezoMUX(); china1.singlePiezoMUX(); china2.singlePiezoMUX(); splash1.singlePiezoMUX(); splash2.singlePiezoMUX();
//Sending MIDI signals. //HEAD if (snare.hit == true) { MIDI.sendNoteOn(snare.note, snare.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(snare.note, 0, 10); } //RIM else if (snare.hitRim == true) { if (snare.velocity > 60) //Rim shot { MIDI.sendNoteOn(snare.noteRim, snare.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(snare.noteRim, 0, 10); } else //Side Stick { MIDI.sendNoteOn(snare.noteCup, snare.velocity * 2, 10); //(note, velocity, channel) MIDI.sendNoteOff(snare.noteCup, 0, 10); } } //HIHAT //MIDI signals are transmitted with this IF statement. //bow if (hihat.hit == true) { //check open or close //1.open if (hihatPedal.openHH == true) { MIDI.sendNoteOn(hihat.noteOpen, hihat.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(hihat.noteOpen, 0, 10); } //2.close else if (hihatPedal.closeHH == true) { MIDI.sendNoteOn(hihat.noteClose, hihat.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(hihat.noteClose, 0, 10); } }
//RIDE //MIDI signals are transmitted with this IF statement. //bow if (ride.hit == true) { MIDI.sendNoteOn(ride.note, ride.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(ride.note, 0, 10); }
//edge else if (ride.hitRim == true) { MIDI.sendNoteOn(ride.noteRim, ride.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(ride.noteRim, 0, 10); }
//cup else if (ride.hitCup == true) { MIDI.sendNoteOn(ride.noteCup, ride.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(ride.noteCup, 0, 10); }
//choke if (ride.choke == true) { MIDI.sendPolyPressure(ride.note, 127, 10); MIDI.sendPolyPressure(ride.noteRim, 127, 10); MIDI.sendPolyPressure(ride.noteCup, 127, 10); MIDI.sendPolyPressure(ride.note, 0, 10); MIDI.sendPolyPressure(ride.noteRim, 0, 10); MIDI.sendPolyPressure(ride.noteCup, 0, 10); }
//CRASH1 //MIDI signals are transmitted with this IF statement. ceash1 //bow if (crash1.hit == true) { MIDI.sendNoteOn(crash1.note, crash1.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(crash1.note, 0, 10); }
//edge else if (crash1.hitRim == true) { MIDI.sendNoteOn(crash1.noteRim, crash1.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(crash1.noteRim, 0, 10); }
//choke if(crash1.choke == true) {
}
//CRASH2 //MIDI signals are transmitted with this IF statement. ceash1 //bow if (crash2.hit == true) { MIDI.sendNoteOn(crash2.note, crash2.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(crash2.note, 0, 10); }
//edge else if (crash2.hitRim == true) { MIDI.sendNoteOn(crash2.noteRim, crash2.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(crash2.noteRim, 0, 10); }
//choke if(crash2.choke == true) {
}
//CRASH3 //MIDI signals are transmitted with this IF statement. ceash1 //bow if (crash3.hit == true) { MIDI.sendNoteOn(crash3.note, crash3.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(crash3.note, 0, 10); }
//edge else if (crash3.hitRim == true) { MIDI.sendNoteOn(crash3.noteRim, crash3.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(crash3.noteRim, 0, 10); }
//choke if(crash3.choke == true) {
}
if (kick1.hit == true) { MIDI.sendNoteOn(kick1.note, kick1.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(kick1.note, 0, 10); }
if (kick2.hit == true) { MIDI.sendNoteOn(kick2.note, kick2.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(kick2.note, 0, 10); }
if (tom1.hit == true) { MIDI.sendNoteOn(tom1.note, tom1.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(tom1.note, 0, 10); }
if (tom2.hit == true) { MIDI.sendNoteOn(tom2.note, tom2.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(tom2.note, 0, 10); }
if (tom3.hit == true) { MIDI.sendNoteOn(tom3.note, tom3.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(tom3.note, 0, 10); }
if (tom4.hit == true) { MIDI.sendNoteOn(tom4.note, tom4.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(tom4.note, 0, 10); }
if (tom5.hit == true) { MIDI.sendNoteOn(tom5.note, tom5.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(tom5.note, 0, 10); }
if (china1.hit == true) { MIDI.sendNoteOn(china1.note, china1.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(china1.note, 0, 10); }
if (china2.hit == true) { MIDI.sendNoteOn(china2.note, china2.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(china2.note, 0, 10); }
if (splash1.hit == true) { MIDI.sendNoteOn(splash1.note, splash1.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(splash1.note, 0, 10); }
if (splash2.hit == true) { MIDI.sendNoteOn(splash2.note, splash2.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(splash2.note, 0, 10); }
if (rimtom1.hit == true) { MIDI.sendNoteOn(rimtom1.note, rimtom1.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(rimtom1.note, 0, 10); }
if (rimtom2.hit == true) { MIDI.sendNoteOn(rimtom2.note, rimtom2.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(rimtom2.note, 0, 10); }
if (rimtom3.hit == true) { MIDI.sendNoteOn(rimtom3.note, rimtom3.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(rimtom3.note, 0, 10); }
if (rimtom4.hit == true) { MIDI.sendNoteOn(rimtom4.note, rimtom4.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(rimtom4.note, 0, 10); }
if (rimtom5.hit == true) { MIDI.sendNoteOn(rimtom5.note, rimtom5.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(rimtom5.note, 0, 10); }
//CRASH4 //MIDI signals are transmitted with this IF statement. ceash1 //bow if (crash4.hit == true) { MIDI.sendNoteOn(crash4.note, crash4.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(crash4.note, 0, 10); }
//edge else if (crash4.hitRim == true) { MIDI.sendNoteOn(crash4.noteRim, crash4.velocity, 10); //(note, velocity, channel) MIDI.sendNoteOff(crash4.noteRim, 0, 10); }
//choke if(crash4.choke == true) {
}
}`