Here is the code i have. UNO R3 to yamaha mu10
//midi controller template
//7-21-2014 update: changed MIDI CONTROL values to hexadecimal from base-10
// added comments
char notes[12] = {10, 9, 8, 7, 6, 5, 4, 3, 2, A2, A3, A4}; //pin setup for 12 buttons (keyboard)
boolean noteOn[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //button (keyboard) state
boolean noteLast[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //last button (keyboard) state
char noteCount = 12;
char changePins[3] = {11, 12, 13}; //pin setup for 3 "modifier" keys
char octaveChanges[3] = {12, -12, 0}; //numbers for octave changing
char singleChanges[3] = {1, -1, 0}; //numbers for half step changing
boolean changeButton[3] = {0, 0, 0}; //modifier button state
boolean changeButtonLast[3] = {0, 0, 0}; //last modifier button state
int keysBase = 0x3C; //base for keyboard (C4)
int keysLast = keysBase; //last keyboard base state
int changekeys(int a, int b){ //function to change key base
keysLast = a + b;
return(keysLast);
}
int pots[2] = {A0, A1}; //pin setup for potentiometers
int potState[2] = {0, 0}; //pot state
int potLast[2] = {0, 0}; //last pot state
int potCount = 2;
void setup(){
Serial.begin(31250); //serial speed for MIDI
}
//MIDI protocol - http://www.midi.org/techspecs/midimessages.php
//note to MIDI number - http://www.phys.unsw.edu.au/jw/graphics/notes.GIF
int midi(int midiStatus, int midiData1, int midiData2){ //MIDI send function
Serial.write(midiStatus);
Serial.write(midiData1);
Serial.write(midiData2);
}
void loop(){
constrain(keysLast, 0x18, 0x60); //limit keyboard from C1 to C7
for(int i = 0; i < 3; i++){ //loop for modifier keys
changeButtonLast[i] = changeButton[i]; //update modifier key state
changeButton[i] = digitalRead(changePins[i]); //read state of modifier keys
if(changeButton[2] && changeButton[i] == HIGH && changeButton[i] != changeButtonLast[i]){ //if modifier buttons 1 or 2 are pressed while modifier button 3 is held down
changekeys(singleChanges[i], keysLast); //change keyboard base up or down in half steps
}
if(changeButton[0] && changeButton[1] == HIGH){ //if modifier buttons 1 and 2 are pressed together simultaneously
keysLast = keysBase; //revert keyboard base to C4
}
if(changeButton[i] == HIGH && changeButtonLast[i] != changeButton[i] && changeButton[2] == LOW){ //if modifier buttons 1 or 2 are pressed while modifier button 3 is released
changekeys(octaveChanges[i], keysLast); //change keyboard base up or down in octaves
}
}
for(char n = 0; n < noteCount; n++){ //loop for the 12 button keyboard
noteOn[n] = digitalRead(notes[n]); //read state of keyboard
if(noteOn[n] == HIGH && noteLast[n] != noteOn[n]){ //if a key(s) is pressed
midi(0x90, keysLast + n, 0x7F); //channel 1 MIDI note(s) ON with static 127 note velocity
noteLast[n] = noteOn[n]; //update keyboard state
}
if(noteLast[n] != noteOn[n]){ //if last keyboard state changes
midi(0x80, keysLast + n, 0x7F); //channel 1 MIDI note(s) OFF
noteLast[n] = noteOn[n]; //update keyboard state
}
}
for(char n = 0; n < potCount; n++){ //loop for potentiometers
potState[n] = (analogRead(pots[n])/4); //read pot state
if(abs(potState[n] - potLast[n]) > 1){ //if potstate changes
midi(0xB0, 0x0C + n, ((potState[n])/2)); //channel 1 MIDI control/mode change
potLast[n] = potState[n]; //update pot state
}
}
}