Is this what you want?
// what midi channel we're sending on
// ranges from 0 15
#define midichannal 9 // Equates to MIDI Channel 10
#define midichannal 10 // Equates to MIDI Channel 11
#define midichannal 11 // Equates to MIDI Channel 12
#define midichannal 12
#define midichannal 13
// general midi drum notes
#define note_F#
#define note_D
#define note_A
#define note_G
#define note_F
// define the pins we use
#define switchAPin 12
#define switchBPin 11
#define switchCPin 10
#define switchDPin 9
#define switchEPin 8
#define ledPin 13 // for midi out status
int switchAState = LOW;
int switchBState = LOW;
int switchCState = LOW;
int switchDstate = LOW;
int switchEstate = LOW;
int ledPinA = A5; //LED connected to analog Pin 5
int ledPinB = A4; //LED connected to analog Pin 4
int currentSwitchState = LOW;
int val,t;
void setup() {
pinMode(switchAPin, INPUT);
pinMode(switchBPin, INPUT);
pinMode(switchCPin, INPUT);
pinMode(switchDPin, INPUT);
pinMode(switchEPin, INPUT);
pinMode(A5, OUTPUT);
pinMode(A4, OUTPUT);
digitalWrite(switchAPin, HIGH); // turn on internal pullup
digitalWrite(switchBPin, HIGH); // turn on internal pullup
digitalWrite(switchCPin, HIGH); // turn on internal pullup
digitalWrite(switchDPin, HIGH);
digitalWrite(switchEPin, HIGH);
//Turn on LED
digitalWrite(A5, HIGH);
digitalWrite(A4, HIGH);
// set MIDI baud rate
Serial.begin(57600);
}
void loop() {
// deal with switchA
currentSwitchState = digitalRead(switchAPin);
if( currentSwitchState == LOW && switchAState == HIGH ) // push
noteOn(0x90, 0x1E, 127);
if( currentSwitchState == HIGH && switchAState == LOW ) // release
noteOff(0x90, 0x1E, 0);
switchAState = currentSwitchState;
//read state of the piezo
currentSwitchState = digitalRead(switchAPin);
//check if piezo is pressed
//if so, the buttonState is HIGH
if(currentSwitchState == LOW) {
//turn on the LED
digitalWrite(A5, HIGH);
}
currentSwitchState = digitalRead(switchBPin);
if( currentSwitchState == LOW && switchAState == HIGH ) // push
noteOn(0x90, 0x2E, 127);
if( currentSwitchState == HIGH && switchAState == LOW ) // release
noteOff(0x90, 0x2E, 0);
switchBState = currentSwitchState;
//read state of the piezo
currentSwitchState = digitalRead(switchBPin);
//check if piezo is pressed
//if so, the buttonState is HIGH
if(currentSwitchState == HIGH) {
//turn on the LED
digitalWrite(A4, HIGH);
}
currentSwitchState = digitalRead(switchCPin);
if( currentSwitchState == LOW && switchAState == HIGH ) // push
noteOn(0x90, 0x3E, 127);
if( currentSwitchState == HIGH && switchAState == LOW ) // release
noteOff(0x90, 0x3E, 0);
switchCState = currentSwitchState;
currentSwitchState = digitalRead(switchDPin);
if( currentSwitchState == LOW && switchAState == HIGH ) // push
noteOn(0x90, 0x4A, 127);
if( currentSwitchState == HIGH && switchAState == LOW ) // release
noteOff(0x90, 0x4A, 0);
switchCState = currentSwitchState;
currentSwitchState = digitalRead(switchEPin);
if( currentSwitchState == LOW && switchAState == HIGH ) // push
noteOn(0x90, 0x5B, 127);
if( currentSwitchState == HIGH && switchAState == LOW ) // release
noteOff(0x90, 0x5B, 0);
switchCState = currentSwitchState;
}
// Send a MIDI note on message. Like pressing a piano key
// channel ranges from 0 15
void noteOn(byte channel, byte note, byte velocity) {
midiMsg( (0x90 | channel), note, velocity);
}
// Send a MIDI note off message. Like releasing a piano key
void noteOff(byte channel, byte note, byte velocity) {
midiMsg( (0x80 | channel), note, velocity);
}
// Send a general MIDI message
void midiMsg(byte cmd, byte data1, byte data2) {
digitalWrite(ledPin,HIGH); // indicate we're sending MIDI data
Serial.write(byte(cmd));
Serial.write(byte(data1));
Serial.write(byte(data2));
digitalWrite(ledPin,LOW);
}