Help- using an arduino to make a midi controller

Hey everyone, I'm new to the forum

I'm Chris

I'm having trouble getting my head around many things, this is my first ever time using an Arduino, And i would greatly appreciate your help

So here goes:

The project is to replicate Mathew Bellamays (from the band Muse) signature guitars that have a built in touch pad. http://www.mansons.co.uk/shopping/images/items/2375/2375_1_medium.jpg<--Image here
The touch pad controls a piece of audio sampling hardware called a http://www.kaosspad.co.uk/images/KaossPad_kp2.jpg<--(KAOSS PAD KP2 in my case) and it does this via MIDI - Wikipedia<--MIDI, the Kaoss pad already has a touch pad built in, along with all the other features I wish to place in my guitar. the point of this is to access all the pads features via midi commands from analogue inputs in my guitar(the touch pad, momentary switch, and a rotary encoder for the effect selection.) as the pad is fairly unusable to a guitarist in its regular state.

I am not the first to want to do this, in fact I know of 2 people who have already done this, here are their videos on youtube:
Kaoss Pad Touch Screen Midi Controller - YouTube"
<--bassman76jazz
Kaoss Pad Touch Screen Midi Controller - YouTube<--
gazlang81

Both examples are made in almost an identical way, although I prefer bassmans approach as although he hasn't revealed much, his came after gazlang and he told me some of the improvements he did on gaz's design.

The overview of the project is:
-To convert an analogue input of a resistive touch screen into midi output signals that the kaoss pad will read.
-To add a Hold Button on the guitar that does the same as the hold button on the pad
-To add a rotary encoder that will allow me to change the effects of the pad on the guitar.
-Have a LED backlight that has a color pattern when not used, but then is responsive to the input of the touch screen.

In the next few steps I'll explain how far I've gotten.

To convert the input signals and to regulate the LED effects I will do the same as the 2 guys I mentioned and I will use a Arduino, I have chosen the http://www.arduino.cc/en/Main/ArduinoBoardProMini <--Arduino mini pro as it was bassman's recomendation. It runs on C++ (a language I know very little about) bassman has given me some tips over email about how the circuit board should be wired etc... so here is an extract of his email to me, and the schematics I have sort of done so far.

Email:
there is not really anything to the circuit, its just the screens four wires into the analog inputs of the arduino, the switch goes from ground to a digital input and the encoder connects to pin 2 and 4 (the interrupt pins) on the arduino the midi jack uses the tx pin and a ground and +5v pins and the led is connected to +5v and three pwm output pins. the pin numbers are arbitrary since they are controlled via the firmware. there are no extra chips, its just the arduino to control everything, the kit that gazlang81 makes uses the arduino mini, mine is the mini pro. as for the c code for the arduino I'm not willing to give this up just yet.

Schematics: (bare in mind I doubt very much that these are right)

If the wires are in the wrong place or not connected at all, Its because I literally don't know any better or where to put them.

here are the components I'd like to use:

for the LED I'd like to use a BlinkM — ThingM<--BlinkM smart LED

The http://www.arduino.cc/en/Main/ArduinoBoardProMini<--Arduino mini pro

http://www.amazon.co.uk/NINTENDO-REPLACEMENT-BOTTOM-SCREEN-TOUCH/dp/B001AHJD3M<--nintendo DS lite touch pad

For the other components I don't know any specific things to buy etc...

Thats all I know about the hardware I need and how to build it.

now for the software for the arduino, I am literally clueless, although I have had somewhat experience with computer languages, I know close to nothing about C++. But what I have is a list of codes that will prove helpful to anyone who does know about C++

here are the links:

http://www.muselive.com/forums.php?m=posts&q=36686:<--Resistive strip midi input for the digitech whammy pedal

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1197235191<--programing a touch pad as a midi input:

here is the manual for the Kaoss pad, In page 12 it has the midi chart(that will tell you what command each midi value is associated with).

Downloads | KORG (USA)<--Kaoss pad manual.pdf

This is as far as I've gotten and all I know.

Also im not sure on how to program the LED but i think that might be much simpler

What I would like to achieve is the same that those 2 guys achieved in their videos. Thankfully the rest I can do and I'm quite good at. I'd appreciate any help at all and thank you very much for your attention whilst reading this.

many thanks

Chris

Well I'll help you out a bit here, the touch screen needs 6 connections :slight_smile:

but it only has 4 cables coming out of it, Y+,Y-, X+ and X-

http://mnicolato.altervista.org/arduino/ardtouch.htm
6 wires needed. I have used one a bit myself.

so what you use the same wire twice?

cus there are literally only 4 wires coming out of the touch screens in the videos I posed. but thanks for the link, its very helpful.

Yes you use 2 wires twice. You need 6 pins so you can change the pins around to be able to read vertical and horizontal positioning.

Mowcius

you can use an analog pin as well as a digital pin..

thanks for all the tips so far.

so this is the code I've written to date:

// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
// Touch panel wiring
// Connect to Arduino these wires (used to drive power)
#define Lo 2 // LEFT to digital output 2
#define Bo 3 // BOTTOM to digital output 3
#define Ro 4 // RIGHT to digital output 4
#define To 5 // TOP to Digital output 5

// Connect to Arduino these wires (used to read the touch position)
#define Ti 3 // TOP also to analog input 3
#define Ri 4 // RIGHT also to analog input 4

#define LED 13 // LED event
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
// current touched
int touchX = 0;
int touchY = 0;
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


void setup()
{
 Serial.begin(31250);//midi=31250   testing=9600 
 pinMode(LED, OUTPUT); 
}

void loop() {
       if (touched())
                   {
                                     /*Serial.print("X=");
                                     Serial.print(touchX); 
                                     Serial.print(" Y=");
                                     Serial.println(touchY); <-old code*/
                   
                  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      
              }
       while analogRead(Ti) > 0 || analogRead(Ri) > 0; //this while loop keeps the LED on whilst the touch pad is being touched
        digitalWrite(LED, HIGH);
       else
        digitalWrite(LED, LOW);
       }

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

       // Horizontal routine - set L to gnd and R to Vcc
       // set L = ground
       pinMode(Lo, OUTPUT);
       digitalWrite(Lo, LOW); 
       // set R = Vcc
       pinMode(Ro, OUTPUT);
       digitalWrite(Ro, HIGH); 
       // T e B high impedance (input mode)
       pinMode(To, INPUT);
       pinMode(Bo, INPUT);
       // wait a bit, then read from Top
       delay(10); 
       touchX = analogRead(Ti); 

       // Vertical routine - set T to gnd and B to Vcc
       // Set B = Vcc
       pinMode(Bo, OUTPUT);
       digitalWrite(Bo, LOW); 
       // set T = gnd
       pinMode(To, OUTPUT);
       digitalWrite(To, HIGH); 
       // R e L high impedance (input mode)
       pinMode(Ro, INPUT);
       pinMode(Lo, INPUT); 
       // wait a bit, then read from Right
       delay(10); 
       touchY = analogRead(Ri);
       
       

       // Only if coords are below 1000 and above 0
       if(0 < touchX < 1000 and 0 < touchY < 1000)
       touch = true;

       return touch;
 }
 

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

I haven't tested this cus I dont yet have all the pieces.

but what It should do is:

-read the touch coordinates of the X and Y Axis
-convert them to midi signals
-transmit the midi signal
-Stop transmitting the midi signal when my finger is off the pad
-have the LED on ONLY when you are physically pressing the touch pad

I am unsure about the midi signal I am sending aswell... cus I just can't read this stupid midi table... the ones i have coded to send are a calculated guess from attempting to read the table. (here is the table by the way, it is on page 11 http://www.korg.com/uploads/Support/KP2_OM_E_633661788715550000.pdf

the last "void" command in the code is also something I am unsure about. I know its necessary...but I'm struggling to understand how it works.

thank you all so much for your help.

I haven't tested this cus I dont yet have all the pieces.

Then you shouldn't be writing a ton of code. Write code only for the hardware you have, and test each piece of hardware separately. Only when a piece works correctly independently should you move on and try to combine it with other hardware.

the last "void" command in the code is also something I am unsure about.

Learning the correct terminology will be helpful. There are functions in the code you posted, not commands. When referring to functions, the return type (void) is completely unnecessary verbiage.

cus I just can't read this stupid midi table

Well, this implies that you are trying to merge hardware you no little about, software you know even less about, with technology you don't understand. Is this a school project, by any chance?

If you focus on one aspect at a time, instead of jumping in the deep end, the whole process will be more pleasant. Get some hardware. Write some code to drive it, or be driven by it. Integrate that hardware with other hardware. Join the code to drive the new hardware with the overall application sketch. Don't move forward until you understand how the hardware and software that you have installed/written play together.

Then you shouldn't be writing a ton of code. Write code only for the hardware you have, and test each piece of hardware separately. Only when a piece works correctly independently should you move on and try to combine it with other hardware.

I see your point, but this code is mainly extracted from several links, and I know that those pieces of code work. So whilst waiting for the hardware, instead of plugging in code that I know will work, I thought I would try and create code that does the basic principle I want my code to do, But I do agree with you that trial and error is most probably the single best way of learning to do this.

Learning the correct terminology will be helpful. There are functions in the code you posted, not commands. When referring to functions, the return type (void) is completely unnecessary verbiage.

After I posted my latest post, I went and extensively researched that void function. I even asked a friend who was a programmer. the problem I have is I don't understand the purpose/format of this line : "void midiCC(char command, char value1, char value2){" as I havent assigned a "command", a "value1" or a "value2", I even used the annotation midiCC twice... problem is every single piece of functioning midi interface code I've seen has it, but no where can I find an explanation as to why.

Well, this implies that you are trying to merge hardware you no little about, software you know even less about, with technology you don't understand. Is this a school project, by any chance?

If you focus on one aspect at a time, instead of jumping in the deep end, the whole process will be more pleasant. Get some hardware. Write some code to drive it, or be driven by it. Integrate that hardware with other hardware. Join the code to drive the new hardware with the overall application sketch. Don't move forward until you understand how the hardware and software that you have installed/written play together.

Your pretty much spot on with my knowledge. But no I'm not at school, I'm actually at university and this is not a project for my degree, This is a personal challenge/hobby I've set myself, as I've wanted to do this since I was about 15, but I only recently found out the proper way to do it. I've just finished my first year of studying mechanical engineering, sadly the only thing that my degree has as a transferable skill is basic programming (I have had to write code in MATLAB). But I've always been fascinated by electronics and I recently found that an arduino bridges that gap between hardware and software. Essentially I'm just looking to broaden my knowledge with this and electronics as I find them very intriguing.

Now when it comes to midi... IT IS HORRIFIC TO FIND A GOOD SOURCE OF KNOWLEDGE FOR IT... I have read through countless hours of junk about midi, starting from the very basics and going to the very complex, on other pieces of guitar equipment I have, I have found exactly the midi information I need. but simply this kaoss pad I feel has a very badly explained table.

personally I think midi is a terrible technology and they shouldn't have done it so early. cus now were stuck with it.

But if someone could help me understand how that table works, or even how that void function works. I would greatly appreciate it.

thanks to all.

Can't help you with the midi table, as you know more about midi than I (care to).

The midiCC function, though, takes 3 arguments. The first is reference, in the function, using the name command. The second is referenced using the name value1. The third is referenced using the name value2.

You call the function this way:
midiCC(0xB0, 12, midix); // sends midi control change for touch pad X axis
midiCC(0xB0, 13, midiy); // sends midi control change for touch pad y axis
So, the function will write the 3 values (0xB0, 12, and midix or 0xB0, 13, and midiy) to the serial port, where the midi-controller is presumably listening.

Well I think that makes sense, Yeah thanks for the help. :slight_smile:

Hey Chris,
I'm new the forum and arduino as well, but I've been trying to accomplish the same thing. What I do know is Gareth's Hold Switch bypasses the "pad off" command sent.

Hope this helps!

Phi

don't listen to mowcius its a resistive touch screen with 4 wires and it uses 4 analog inputs with resistors to ground

don't listen to mowcius its a resistive touch screen with 4 wires and it uses 4 analog inputs with resistors to ground

Umm, you must be new here.

That's not how things work around this forum. If you can provide some tried and tested code to show some method with only 4 analog inputs (and some pull down resistors) working then I will happily accept your statement.

Please don't say things like 'don't listen to'. It's not really in the spirit of this forum. I might just go and say something like, "don't listen to bassman76jazz, he's a noob with 1 post and doesn't know anything about what he's talking about" but under normal circumstances I would not ever say something like that.

Basically, please provide some more details on this method and try to be a bit more constructive on the forum in future.

Mowcius

Im new here but have come accross this site that details how to use a four wire resistive touchscreen with an arduino and 10k ohm resistors to earth. I have not tested the code yet however.

I cant post the site up though as its my first post..

http://kalshagar.wikispaces.com/Arduino+and+a+Nintendo+DS+touch+screen

I see what they did, seems like a nice way to do it. Well thank you for providing a link.

Mowcius

Which one would you recommend I use? I does one have a clear advantage to the other?

Which one would you recommend I use? I does one have a clear advantage to the other?

Well one uses 4 pins and one 6. I would not have thought it mattered. As long as they tell you the position, they presumably do what you want them to do.

Mowcius