need help using arduino as midi controller for kaoss pad

hi everyone,

what i have is; an arduino uno, a 4 wire resistive touch screen (taken from a nintendo ds xl), a blinkM smart LED, and a momentary switch, and a korg kaoss pad kp3. what i want to do is program my arduino to read the touch screen and the momentary switch then convert the messages and values from them, turn the readings into midi data, then send that midi data for control change one the kaoss pad.

The way i want it to work is for the touch screen (from the nintendo ds) to act as a remote controller for the touch screen already existing in the kp3. i also want the momentary switch to do the same funtion as the HOLD button that is already on the kp3. while all of this is happening, i want the blinkM LED to chnge colours at its own pace while the ds touch screen is not in use, but when the ds touch srenn is in use, have the led change colours as the values on the ds touch screen change.

This is the sketch i have written so far:

/*****************************************
// Jayke's Midi Pad Code
//
//Reads a 4 wire touch screen and a momentary switch
//
//Sends serial data on channel 1 to a korg KP3
//
//Sends serial data to a blinkM Smart LED
//
//Connect one pin of the switch to GND, the other to D9 on the
Arduino
//Connect the +X axis pin of the touch screen to AD0 on the arduino (a second
wire goes to a 10k ohm resistor then to GND)
//Connect the -X axis pin of the touch screen to AD1 on the arduino (a second
wire goes to a 10k ohm resistor then to GND)
//Connect the +Y axis pin of the touch screen to AD2 on the arduino (a second
wire goes to a 10k ohm resistor then to GND)
//Connect the -Y axis pin of the touch screen to AD3 on the arduino (a second
wire goes to a 10k ohm resistor then to GND)
//Connect one pin of blinkM smart LED to D3 on the arduino
//Connect one pin of blinkM smart LED to D5 on the arduino
//Connect one pin of blinkM smart LED to D6 on the arduino
//Connect one pin of blinkM smart LED to 5v
//
//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 analogPin0 0 // touchXhigh

#define analogPin1 1 // touchXlow

#define analogPin2 2 // touchYhigh

#define analogPin3 3 // touchYlow

#define digitalPin9 9 // momentary switch

#define Debounce 30

int touchXhighValue = 0;

int touchXlowValue = 0;

int touchYhighValue = 0;

int touchYlowValue = 0;

int switchValue = 0;

int switchState = 0;

int touchXhighValueLast = 0;

int touchXlowValueLast = 0;

int touchYhighValueLast = 0;

int touchYlowValueLast = 0;

byte i,valt;

void setup() {
  
  Serial.begin(31250);  // set MIDI baud rate
  
  Serial.flush();
  
  
  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 for korg kaoss pad
    
   delay(Debounce);
   
  }
  
  if(switchValue ==HIGH && switchState ==1){
    
    switchState =2;
    
  }
  
  
  if(switchValue ==LOW && switchState ==2){  // second press
  
   switchState =3;
   
    midiCC(0xB0, 0, 0); // sends effect hold for korg kaoss pad
    
   delay(Debounce);
   
  }
  
  if(switchValue ==HIGH && switchState ==3){
    
    switchState =0;
    
  }
  
 
  //Read touchXhigh
  
  
  touchXhighValue = analogRead(analogPin0);
  
  if(touchXhighValue != touchXhighValueLast){
    
    touchXhighValue = map(touchXhighValue,0,1016,0,127); //maps the value range of touchXhigh to midi 0->127

   midiCC(0xB0, 12, touchXhighValue); // sends midi control change for korg kp3 touch pad

  touchXhighValueLast = touchXhighValue;
  
  }
 
  //Read touchXlow
  
  
  touchXlowValue = analogRead(analogPin1);
  
  if(touchXlowValue != touchXlowValueLast){
    
    touchXlowValue = map(touchXlowValue,0,1016,0,127); //maps the value range of touchXlow to midi 0->127

   midiCC(0xB0, 12, touchXlowValue); // sends midi control change for korg kp3 touch pad

  touchXlowValueLast = touchXlowValue;
  }
  
  //Read touchYhigh
  
  
  touchYhighValue = analogRead(analogPin2);
  
  if(touchYhighValue != touchYhighValueLast){
    
    touchYhighValue = map(touchYhighValue,0,1016,0,127); //maps the value range of touchYhigh to midi 0->127

   midiCC(0xB0, 13, touchYhighValue); // sends midi control change for korg kp3 touch pad

  touchYhighValueLast = touchYhighValue;
  
  }
 
  //Read touchYlow
  
  
  touchYlowValue = analogRead(analogPin3);
  
  if(touchYlowValue != touchYlowValueLast){
    
    touchYlowValue = map(touchYlowValue,0,1016,0,127); //maps the value range of touchYlow to midi 0->127

   midiCC(0xB0, 13, touchYlowValue); // sends midi control change for korg kp3 touch pad

  touchYlowValueLast = touchYlowValue;
  }
}

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

what this should do (fingers crossed) is:

  • read the momentary switch
  • send serial for control change on the korg kaoss pad for the hold button
  • read the ds touchscreen
  • send serial for control change on the korg kp3 for the touch pad

i havent done anything for the blinkM smart LED yet, as i have no idea where to start with it

can anyone please look over the code and tell me if A: im going in the right direction, or B: give me some pointers with my code, C: help me with programming the BlinkM LED?

any help, comments, suggestion at all would be greatly appreciated

thanks

is anybody able to help me at all?

Hi,

jaykebaldwin89:
what i have is; an arduino uno, a 4 wire resistive touch screen (taken from a nintendo ds xl), a blinkM smart LED, and a momentary switch, and a korg kaoss pad kp3. what i want to do is program my arduino to read the touch screen and the momentary switch then convert the messages and values from them, turn the readings into midi data, then send that midi data for control change one the kaoss pad.

Sounds reasonable.

The way i want it to work is for the touch screen (from the nintendo ds) to act as a remote controller for the touch screen already existing in the kp3.

Huh? You want the DS touch screen to control the KP3 touch screen? I don't understand how that would work.

i also want the momentary switch to do the same funtion as the HOLD button that is already on the kp3.

Is there a MIDI command for that?

while all of this is happening, i want the blinkM LED to chnge colours at its own pace while the ds touch screen is not in use, but when the ds touch srenn is in use, have the led change colours as the values on the ds touch screen change.

You need to break the project into smaller manageable pieces. The BlinkM animation, in my opinion, would be a good place to start. I suspect you can find existing code that does some of what you want. Debugging is a breeze; all you need is a functioning eyeball.

One helpful hint: Do not use delay. Under any circumstances.

what this should do (fingers crossed) is:

There is a very high probability that you are the only person on this planet with that exact hardware. Which means that you, and only you, can determine if the application is doing those things.

i havent done anything for the blinkM smart LED yet, as i have no idea where to start with it

This looks promising...
http://todbot.com/blog/2008/01/25/blinkm-hello-video-guides-example-code/

C: help me with programming the BlinkM LED?

Take a stab at getting it to work. If it does not work, post the sketch, describe what should happen, describe what does happen, ask for help. If it does work, post the sketch, ask for a code review.

thanks for the tip on the blinkM, i'll give it a shot when i get a spare chance.

Huh? You want the DS touch screen to control the KP3 touch screen? I don't understand how that would work.

Basicly the ds touch screen has been pulled right out of the ds and conected directly to the arduino so the way i can mount it to my guitar and use it as an external controller for the kp3

im fairly sure i wrote a command for the momentary switch that is conected to my arduino to send the data for control change on the kp3 to activate and de-activate the hold function

i might have written it wrong though, coz i tried it and it doesnt work, so im still trying to work my way around that problem. if i get the hold button to work i'll post how i did it, but in the meen time, my biggest concern is to get the touch screen to connect to the arduino board so i can actually test it. any suggestions?

speaking of which, im able to get my hands on clips for a ds touch screen no problems, but iv gone through about 6 clips trying to connect wires to them so i can hook it up to my arduino board. the main reason for this is due to the fact that the clips are so small (I'm talking a couple of millimeters in size) that any attempt to solder wire to them pulls the pins out of the clips, and pretty much destroys them. can anyone think of a way to connect wires to a ds clip without making it useless?

ok so i've had time to connect the screen and test the sketch i have written. lets start with the momentary switch. It does nothing at all. What i want it to do is trigger the hold button on my kaoss pad, turning the hold function on when i press the momentary switch connected to my arduino uno board, then when i press it again, have it turn the hold function off on the kaoss pad. but it does nothing at all.

now the touch screen, it works kind of... what i meen is, it will take the readings from the screen i have connected to the kaoss pad, and send the data for control change for the kaoss pad, but it has a few problems...

1: when i touch the screen connected to my arduino board, it will give the same readings on the kaoss pad for a split second, then for reasons unknown, the kaoss pad will act as if your finger is touching somewhere on the bottem of the screen near the bottem left corner.

2: when i am not touching the screenthe kaoss pad will still act as if your finger is touching somewhere on the bottem of the screen near the bottem left corner.

I still havnt done anything for the blinkM led yet, but at the moment, my biggest concern is trying to get the touch screen to work properly, and to get the hold button to work. i want to get this sorted before i move onto the BlinkM LED.Does anybody know where i might be going wrong with my project?