int buttonPin = 2;
boolean currentState = LOW;//stroage for current button state
boolean lastState = LOW;//storage for last button state
void setup(){
pinMode(buttonPin, INPUT);//this time we will set the pin as INPUT
Serial.begin(9600);//initialize Serial connection
}
void loop(){
currentState = digitalRead(buttonPin);
if (currentState == HIGH && lastState == LOW){//if button has just been pressed
MIDImessage(176,1,buttonPin);//turn note 60 on with 127 velocity
delay(2);//crude form of button debouncing
} else if(currentState == LOW && lastState == HIGH){
MIDImessage(176,1,buttonPin);//turn note 60 on with 127 velocity
delay(10);//crude form of button debouncing
}
lastState = currentState;
}
//send MIDI message
void MIDImessage(byte command, byte data1, byte data2) {
Serial.write(command);
Serial.write(data1);
Serial.write(data2);
}
cualquier vídeo tutorial , pagina o su propia sapiencia sera de mucha ayuda