Help- using an arduino to make a midi controller

ok

i've done my personal kit...
thank you to ones helped me.

just curious, how have you guys attached the touch pad to the guitar? I.E, have you put a frame around the touch pad? and if so, how did you make it?

I'm not too happy with my frame, so I want to remake it, im just curious for ideas. cheers.

also, the hold function. I was just reading the owners manual for the KP3, and that has an actual hold command...which is midiCC(0xB0, 95, 127).

but on the KP2 that is MUTE, so im wondering what command you guys used for the hold function. did you use the 92 on/off command?

also my code isnt running as smoothly on the drum machine as I want it to. I have a feeling its because of the constant sending of coordinates, as when I move my finger on the kaoss pad itself, the drum effect changes but remains in rhythm. if i do it on my pad, it doesnt. i think it might just be with sending the touch ON code too many times. but im not sure.

let me know guys.

cheers.

this might be a bit off topic but.. MERRY CHRISTMAS EVERYONE! :smiley:

well how was everyones Christmas?? ::slight_smile:

it was fun, I upgraded the code so that it should work on KP3...sadly i dont have a KP3 to test it with.

I also made it so the LED blinks when settings are being changed, for example when the HUE cycle is being changed or when you choose between the whammy and the KP2.

How is the midi signal for rotary encoder? :-?

suryavoice, dude ill give you a hand with your encoder, and in exchange could i ask for a favor? you see i dont have a KP3 so I can't test the code i wrote for it. but in theory it should work. if you could PM me your encoder code, ill see what I can do, and if its ok ill PM you a message asking you to test a bit of code, (its just the hold function i need testing).

anyway buddy, hope you had a good holiday!

let me know

;D ;D ;D ;D ;D

you helped me so much chris...so i can test for you everything you want. Post me your code, and today i'll do it for you!

I'm using the rotary encoder code (the same you posted here)
I have rotary connected to pins digital 10 and 11, with ground that make a bridge. I'm not using a resistor yeyt, and i hope to don't need one. I have opened a gareth's kit, and there was only midi resistor.

Bye my friend

have you guys checked this out?? http://twocherriesinstruments.ecrater.com/p/10007783/kaoss-pad-midi-controler-kit-with-75-in#

hy guys
please give me help for my code my touch pad works but i don't know to send midi data i'm in trouble i don't understand for insert correctly the midi commands lines into my code!!!
(sorry for my bad english)

thanks for the plug Supper Matt! if your not up to the challenge of building a FSM then get my kit :wink: I have new Videos up on my new channel at youtube just look for TwoCherriesIns... on the encoder I use the interrupts so check them out in the learning section.
http://twocherriesinstruments.ecrater.com/

OK, I am building one of these devices, I designed and coded 90% of it before looking at this thread. ill share my code here and see what you think so far. I am having trouble with the code for the BlinkM, but thats in another thread so ill skip it.

//Touchpad
#define TouchX 0 // X axis
#define TouchY 1 // Y Axis
//Rotary Encoder
#define RotorA 3 //Interrupt pin 1
#define RotorB 6 //Digital IO 6
//Hold button
#define HoldButton 2 //Interrupt 0
//Switches
#define S1 4 //GP button 1
#define S2 5 //GP Button 2
#define debounce 10 //Debounce value
//Led
#define LED 13 // LED Pin

//Touchpad Variables
int touchX = 0;
int touchY = 0;

//Hold Flag
volatile int holdflag = LOW; //Hold Flag

//Rotary encoder
int currVal = 1; //Value of rotation

void setup()
{
      //Serial Setup for output of MIDI
      Serial.begin(31250);//midi=31250 baud
      
      pinMode(LED, OUTPUT);
      
      attachInterrupt(0, hold, HIGH);//Hold Button interrupt pin
      attachInterrupt(1, rotate, HIGH);//Rotary Encoder interrupt pin
      //Blinkm I2C setup
      Wire.begin();                // set up I2C on 4 and 5 analog
      Wire.beginTransmission(0x09);// join I2C, talk to BlinkM 0x09
      Wire.send('c');              // 'c' == fade to color
      Wire.send(0xff);             // value for red channel
      Wire.send(0xff);             // value for blue channel
      Wire.send(0xff);             // value for green channel
      Wire.endTransmission();      // leave I2C bus 
}

void loop() {
      if (touched())
      {
            midiCC(0xB0,92,127); //Touchpad down command
            midiX = map(touchX,0,1016,0,127);  // maps the value range of the axis to midi 0->127
            midiCC(0xB0, 12, midix);  // sends midi control change for touch pad X axis

            midiy = map(touchy,0,1016,0,127);  // maps the value range of the axis to midi 0->127
            midiCC(0xB0, 13, midiy);  // sends midi control change for touch pad y axis
            
      }
      else
      {
            if(holdflag)
            {
                  digitalWrite(LED, HIGH);
            }
            else
            {
                  midiCC(0xB0,92,0) //Touchpad off
                  digitalWrite(LED, LOW);
            }
      }

      // return TRUE if touched, and coords in touchX and touchY
      boolean touched()
      {
            boolean touch = false;

            // wait a bit, then read from Top
            delay(10);
            touchX = analogRead(TouchchX);

            // wait a bit, then read from Right
            delay(10);
            touchY = analogRead(TouchchY);

            // Only if coords are below 1000 and above 0 
            //TODO set up calibration for not touching.
            if(0 < touchX < 1000 and 0 < touchY < 1000)
            touch = true;

            return touch;
      }

      //Toggles hold on interrupt 0 goes high
      void hold()
      {
            delay(debounce) //Wait a bit
            if(digitalRead(HoldButton) == HIGH) //Check if its still toggled.
            {
                  holdflag = !holdflag; //Set flag
            }
      }
      
      //Interrupt called by rotary encoder interrupt
      void rotate()
      {      

            if(digitalRead(RotorB) == HIGH) //Interrupt is called, means RotorA has changed, direction can be found by lookign at RotorB
            currVal++; //If High, ++
            if(digitalRead(RotorB) == LOW)
            currVal--; //If low, --
            
            //sanitise output and wrap to 127 programs.
            if(currVal > 127)
            currVal = currVal - 127;
            if(currVal < 0)
            currVal = currVal + 127;
            
            midiCC(0xB0,0xC0,currVal); //0xC0 is the Program change cc so send midi command.

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

Ideas and comments please.

Oh, and if you guys use Fritzing, heres my pics. Based on a Arduino Pro Mini, with hold button (on interrupt pin) rotary encoder(on interrupt) and two other non interrupt based buttons for no defined use yet.

your midi out for the rotary encoder won't work. it should be
midi(0XC0, 0, value);

you also might need +5v on the center pin of the rotary encoder.
other than that it looks ok...

http://twocherriesinstruments.ecrater.com/

your delays are short but you might want to try a FSM...

a friend of mine is selling a complete kaoss pad guitar check it out at my website
http://www.wix.com/twocherriesins/home

When you say fsm are you referring to a Finite State Machine? Also, I thought the program change command needed a controller number as well as a command number?

Yes, finite state machine. And no if you look at the midi specification program change only takes one value, I do not know why it needs to be in the second spot...