Ok, So I am currently in the process of making an Arduino powered electronic drum kit for a school project. I also have to demo it at the New Zealand Institute of Technology in one and a bit weeks. So Fun...
I currently have 6 piezo electric sensors in parallel with a one mega Ohm resistor, with one lead going to ground and one going to a0 etc. I also have a midi port correctly connected to the arduino, with the serial data going to it via the Tx pin of the Arduino (I'm using a midi-USB cable). My problem is that I can't get the Midi messages going to Fl studio or Hydrogen drum machine, or anything for that matter. I'm wondering if anyone has any ideas on how to make this work (I'm using Windows 10)
Here is my current code:
Also, I need the changes to the code to be easily understandable, or explained well
Thanks in advance
void setup() {
// put your setup code here, to run once:
Serial.begin(31250); //Starts the serial link running at approx Midi speed
}
void loop() {
// put your main code here, to run repeatedly:
int Snare = analogRead(A0); //Initialises the variable Snare to the value of A0
int lTom = analogRead(A1); //Initialises the variable lTom to the value of A1
int rTom = analogRead(A2); //Initialises the variable rTom to the value of A2
int fTom = analogRead(A3); //Initialises the variable fTom to the value of A3
int hHat = analogRead(A4); //Initialises the variable hHat to the value of A4
int Ride = analogRead(A5); //Initialises the variable Ride to the value of A5
int SnareThresh = 100; //Sets the threshold for the Snare to 100
int lTomThresh = 100; //Sets the threshold for the Left Tom to 100
int rTomThresh = 100; //Sets the threshold for the Right Tom to 100
int fTomThresh = 100; //Sets the threshold for the Floor Tom to 100
int hHatThresh = 100; //Sets the threshold for the High Hat to 100
int RideThresh = 100; //Sets the threshold for the Ride to 100
// 100 is currently being used as a placeholder value, The kit will eventually have buttons to change the sensitivity of each drum.
if (Snare > SnareThresh) { //Asks if the value for the Snare variable is higher than its respective threshold value
noteOn(0x90, 37, 127); //Sends MIDI data to another loop starting a midi note
delay(05); //Sets a delay for 5 milliseconds, so that the data does not become corrupt
noteOn(0x90, 00, 000); //Sends MIDI data to another loop ending a midi note
}
if (lTom > lTomThresh) { //Asks if the value for the Left Tom variable is higher than its respective threshold value
noteOn(0x90, 03, 127); //Sends MIDI data to another loop starting a midi note
delay(05); //Sets a delay for 5 milliseconds, so that the data does not become corrupt
noteOn(0x90, 00, 000); //Sends MIDI data to another loop ending a midi note
}
if (rTom > rTomThresh) { //Asks if the value for the Right Tom variable is higher than its respective threshold value
noteOn(0x90, 05, 127); //Sends MIDI data to another loop starting a midi note
delay(05); //Sets a delay for 5 milliseconds, so that the data does not become corrupt
noteOn(0x90, 00, 000); //Sends MIDI data to another loop ending a midi note
}
if (fTom > fTomThresh) { //Asks if the value for the Floor Tom variable is higher than its respective threshold value
noteOn(0x90, 07, 127); //Sends MIDI data to another loop starting a midi note
delay(05); //Sets a delay for 5 milliseconds, so that the data does not become corrupt
noteOn(0x90, 00, 000); //Sends MIDI data to another loop ending a midi note
}
if (hHat > hHatThresh) { //Asks if the value for the High Hat variable is higher than its respective threshold value
noteOn(0x90, 04, 127); //Sends MIDI data to another loop starting a midi note
delay(05); //Sets a delay for 5 milliseconds, so that the data does not become corrupt
noteOn(0x90, 00, 000); //Sends MIDI data to another loop ending a midi note
}
if (Ride > RideThresh) { //Asks if the value for the Ride variable is higher than its respective threshold value
noteOn(0x90, 01, 127); //Sends MIDI data to another loop starting a midi note
delay(05); //Sets a delay for 5 milliseconds, so that the data does not become corrupt
noteOn(0x90, 00, 000); //Sends MIDI data to another loop ending a midi note
}
}
void noteOn(int cmd, int pitch, int velocity){ //When noteOn is called for in the previous loop, the 0x90, the xx and the xxx are set to variable intigers
Serial.write(cmd); //Writes the command (generally 0x90 to start a note) to serial
Serial.write(pitch); //Writes the pitch or note number to serial
Serial.write(velocity); //Writes the velocity (usually 127) to serial
}
Custom_Midi_Code.ino (3.78 KB)