need help using an arduino as a midi controller for kp3

im trying to put together a control using an arduino uno board, a blinkm smart led, a momentary switch, and a four wire resistive touch screen (taken from a nintendo ds xl), to use as an external midi controller for a korg kp3. i have started a sketch to test the hold button, but it doesnt work when i connect it all to the kp3. iv looked over this small start iv made in the sketch iv made, and it compiles with no problems, so im under the impression that the values i have in the code are incorrect somewhere along the line. as i said the code i have written so far is only for the hold function on the korg kp3. so basicly im a long way off completing the rest of it for the touch screen and led. what i want the touch sreen to do is act like the touch screen in the kp3, but so i can have the screen itself mounted to the face of my guitar. as for the BlinkM LED, i want that to cycle through colours at its own pace, but when the touch screen is in use, i want the led to blink differant colours when the values of the touch screen values change.

im not the first person to attempt this, these links will show you what i want to acheive:

so this is the sketch i have written so far:

// Jayke's Midi Pad Code
//Sends serial data on channel 1 to a korg KP3
//Connect one pin of the switch to GND, the other to D9 on the
//Midi socket is connected as: (looking from behind at the pins)


//   __---__

//  /  2  \   Pin 2 -> GND

//  ( 4  5 )   Pin 4 -> 220ohm resistor -> 5v

//  \ 1  3 /   Pin 5 -> 220ohm resistor -> Arduino TX Pin

//   """""     Pins 1 / 3 open


#define digitalPin9 9 // momentary switch

#define Debounce 30

int switchValue = 0;

int switchState = 0;

byte i,valt;

void setup () {
  Serial.begin(31250);  // set MIDI baud rate
  for (i = 2; i <=11;i++){ //turn on internal pullups for switches
   digitalWrite(i, HIGH);


void loop() {
  //Read momentary Switch
  switchValue = digitalRead(digitalPin9);
  if(switchValue ==LOW && switchState ==0){ //first press
   switchState =1;
    midiCC(0xB0, 0, 127); // sends effect hold on for korg kp3
  if(switchValue ==HIGH && switchState ==1){
    switchState =2;
  if(switchValue ==LOW && switchState ==2){ // second press
   switchState =3;
    midiCC(0xB0, 0, 0); // sends effect hold off for korg kp3
  if(switchValue ==HIGH && switchState ==3){
    switchState =0;

void midiCC(char command, char value1, char value2){
  Serial.print(command, BYTE);
  Serial.print(value1, BYTE);
  Serial.print(value2, BYTE);

Can anyone please help me out with this?

Can anyone please help me out with this?

What do you need help with? What does that sketch do that you don't want? What does it not do that you do want?

ok so basicly i want this sketch to trigger the hold function on a korg kp3, but it wont do so. iv loaded the sketch onto the arduino board, wired it all up and it wont do anything with the korg kp3. Can someone please look at my sketch to see if i have the values correct, or if i need to re-write the sketch all together. once i get this sorted i will be able to work on the sketch for the external touch screen to control the values of the touch screen that is on the Korg kp3