Hello Arduino board users!
I have wanted for a long time to make my own electrical drum kit, but before i stumbled upon Arduino i used to think i had to buy some expensive MIDI brain for it to work.
Upon discovering arduino and its ability to control MIDI softsynths, I decided to try to build one that would interface with hydrogen through a JACK connection on my legacy laptop with Ubuntu studio installed.
I do not want the signal to travel via an external midi device, but rather via the USB port. To do this, i have found ttymidi to be a great tool. I have written some code to make a button that triggers a midi note to test the feasibility of the project, and so far so good.
I have now ordered the “SpikenzieLabs Drum Kit - Kit” with two extra piezos and hope to be able to write most of the code myself. I am a total rookie to Arduino, and a moderate level MATLAB programmer and Linux user.
Code for the button test:
//Drum Button Code
//needs arumidi.h which is supplied with ttymidi
#include <ardumidi.h> //Midi library from ttymidi
int ledPin = 13; //want the internal LED to light when note is on
int buttonPort = 2; //button connected to digital input 2
int value = 0; //definition of the value to decide whether to giv note on signal or not
int rplay = 0; //define a variable to tell if the note status is already on
int rstop = 0; //define a variable to tell if the note status is already off
void setup()
{
Serial.begin(115200);
pinMode(ledPin, OUTPUT); //LED is lit when button is pushed
pinMode(buttonPort, INPUT); //The button is used as input to play the midi note
}
void loop()
{
value = digitalRead(buttonPort); //Is the button pushed?
if (value == HIGH){ //if YES
if (rplay != 1){ //if note is not already on
midi_note_on(0, 36, 127); //play note 36, which corresponds to first drum in hydrogen list
rplay = 1; //set last ON/OFF action to ON
rstop = 0; //
}
digitalWrite(ledPin, HIGH); //light up LED
}
else{ //If button is not pushed
if (rstop != 1){ //If last ON/OFF action is ON
midi_note_off(0, 36, 127); //Turn off the midi note
rplay = 0; //Set last ON/OFF action to OFF
rstop = 1; //
}
digitalWrite(ledPin, LOW); //turn off LED
}
}
I am usually very bad at commenting my code, but i made an effort this time.
It might be very obvious through the button placement and stuff like this that I learned what little I know of Arduino programming from the webcast tutorial of Button controlled LED, and the buttons circuit is set up in the same way as in that tutorial.
Hoping for feedback on the code and ideas for the project.