Help with sketch for midi drum kit

I'm totally new to this so there are a number of things about to follow that will be very noob.

I have bought an arduino unit in hop of ehooking up my rock band drum kit and playing Ableton live via midi through the serial port.

I have all the parts but the code side of things has me confused. I cannot code but was told I could just find someone else's sketch (is that the right term?) and just paste it into the software and I'd be fine.

But there are so may out there I don't know how you know which cot choose..?

I spoke to the person who told me I could just paste one an they have since told me not to do that and that I must custom write one just for my board. I told them I didn't know how to epoch they added "after I have written the sketch , I need to find a library to attach to the end of it and only then will my code run"

The more i ask them about it the more complex it gets and they suggested it is beyond . They have offered to take the arduino off my hands if I decide to give up….(I have now become suspect of their intentions) but am still at the point of not knowing where to start . I have various coding used by people but am not sure if it is as simple as just pasting it into the software and I'm set.

Any advice or tips ?

I was looking at this code to try

//Piezo midi drum code by Jacob Clarke

int drumPins[] = {A2,A1,A4,A5}; // my A3 pin stopped working somehow
int drumVals[4];
int ledPins[] = {8,9,10,11};
int minPin = A0;
int drumNotes[] = {17,48,43,52};

int minPot = 0;
int minVal = 0;
int maxPot = 0;
int maxVal = 130;

int drumWait[] = {0,0,0,0};
int waitTime = 200; //milliseconds


boolean debug = false;

void setup() {
  if(debug) Serial.begin(9600);//correct speed for serial monitoring
  else Serial.begin(31250);//correct speed for MIDI
  
  //init LEDs
  for(int i=0; i<sizeof(ledPins); i++) {
    pinMode(ledPins[i], OUTPUT);
  }
}

void loop() {
  
  minPot = analogRead(minPin);
  
  //loop through pads
  for(int i=0; i<sizeof(drumPins); i++) {
    
    if(drumWait[i] > 0) {
      
      drumWait[i]--;
      
      //power LED during wait time
      int bright = map(drumWait[i],0,waitTime,0,400);
      if(bright > 255) bright = 255;
      analogWrite(ledPins[i],bright);
      
    }else if(drumWait[i] == 0) {
      if(!debug) {
        
        //trigger note off at the end of wait time
        Serial.write(0x80);
        Serial.write(drumNotes[i]);
        Serial.write(0x00);
        
      }
      drumWait[i]--;
    }else{
      
      //check piezo value and compare to minimum velocity
      int val = analogRead(drumPins[i]);
      if(val > minPot) {
        
        //map the piezo hit to a 127 midi velocity value
        drumVals[i] = map(val,minPot,maxVal,30,127);
        if(drumVals[i] >= 128) drumVals[i] = 127;
        
        if(debug) {
          
          Serial.print(i);
          Serial.print(" Drum = ");
          Serial.println(drumVals[i]);
          
        }else{
          
          //trigger note on for predetermined MIDI note
          Serial.write(0x90);
          Serial.write(drumNotes[i]);
          Serial.write(drumVals[i]);
          
        }
        drumWait[i] = waitTime;
      }
    }
  }
}

thanks to the original author

Hi

I'm new to this too but about to finish my first project of the midi sequencer. I personally would recommend starting any project from scratch just cause if you take a project from someone else, unless they give you really full detail of everything they have done, you might do something slightly different and end up spending ages trying to figure out what you have done. Plus you learn so much more from starting from scratch. Also helps if you want to expand or revise your project later on. I would tho recommend taking section of code (arduino tutorials, great for this) you know works and adapting that, save you the hassle of writing out something someone has already done.

Anyway, Is your rock band drums for the wii as I know and have done, you can connect a wii controller via bluetooth to a computer and convert it to midi via an app (OSCulator), Figured it might make things easier than trying to attach an arduino.

If not with regards to your code, I did notice that to me your MIDI code doesn't look right. I'd recommend having a read of the tutorials for arduino and especially the midi section. They can be found here:

Hope this helps

Thanks

Hi

exist some way to connect ARDUINO as midi controller via his own usb/power connection in a way to connect 3 push button to several pin to act like midi push button controller ??

Did you look at the MIDI tutorial linked in post 2?

yup but i was lookingofr something else thank you the same :&

If your question is very different from the original thrust of this thread, you would benefit from starting your own thread with a relevant subject line.

Hey @polymorph i followed your suggest
i started a new post .thank you, check this one
http://forum.arduino.cc/index.php?topic=267061.msg1883032#msg1883032

Here is a sketch i made that might help, its very simple, just follow my notes and you should be fine.

code is made for Hihat... Kick... Snare... Crash... Tom1... Tom2... Tom3... and Ride.

ENJOY!

The .ino file is attached.

please reply and tell me what you think!

Full_Drum_Kit.ino (8.48 KB)

tried your code and got this error

Arduino: 1.6.7 (Windows 7), Board: "Arduino/Genuino Uno"

C:\Users\blank\Downloads\Full_Drum_Kit\Full_Drum_Kit.ino: In function 'void loop()':

Full_Drum_Kit:67: error: 'A8' was not declared in this scope

int tom3A8 = analogRead(A8); // Value from Pin // Tom3 //

^

exit status 1
'A8' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

That is because A8 is not valid for the Uno. A0 to A5 only.

duh, thank you marco, guess i'll try it with the mega, but if i wanted to use the uno how would i go about modifying justins code. cuz the last time i tried to modify someones code it turned into a nightmare i would not like to repeat. and thanks for taking the to help a noob such as myself

Code should work except for things like missing resources. If the original code used all A0 thru A5 then you actually don't have enough resource. Mega also has many more digital I/o.

so that code gave me the same error using the mega?

Arduino: 1.6.7 (Windows 7), Board: "Arduino/Genuino Uno"

C:\Users\blank\Downloads\Full_Drum_Kit\Full_Drum_Kit.ino: In function 'void loop()':

Full_Drum_Kit:67: error: 'A8' was not declared in this scope

int tom3A8 = analogRead(A8); // Value from Pin // Tom3 //

^

exit status 1
'A8' was not declared in this scope

scratch that, sorry my bad forgot to switch to the mega in settings

what is here wrong, i the this sketch?

//líbrerias necesarias
#include <SD.h>  
#include <SPI.h>
#include <TMRpcm.h>  
#include <CapacitiveSensor.h>

#define pinSD 10     //define el pin para seleccionar la tarjeta SD

TMRpcm tmrpcm;   //Se crea un objeto de la librería TMRpcm

CapacitiveSensor   cs_14_2 = CapacitiveSensor(14,2); // define pines en arduino uno el 14 es A0.
CapacitiveSensor   cs_14_3 = CapacitiveSensor(14,3);
CapacitiveSensor   cs_14_4 = CapacitiveSensor(14,4);
CapacitiveSensor   cs_14_5 = CapacitiveSensor(14,5);
CapacitiveSensor   cs_14_6 = CapacitiveSensor(14,6);
CapacitiveSensor   cs_14_7 = CapacitiveSensor(14,7);
CapacitiveSensor   cs_14_8 = CapacitiveSensor(14,8);

int sense = 400;  // define sencibilidad a menor numero mas sencible
int tiempo = 100; // define tiempo maximo de reproduccion


void setup(){
  tmrpcm.speakerPin = 9; // define el pin en el que está conectada la bocina
  Serial.begin(9600);    

  if (!SD.begin(pinSD)) {  // verifica la coneccion de la tarjeta sd:
    Serial.println("Fallo en la tarjeta SD");  //Aviso de que algo no anda bien 
    return;   //No hacer nada si no se pudo leer la tarjeta
  }
}

void loop(){  
  
   long valor1 =  cs_14_2.capacitiveSensor(20);
 
 if (valor1 > sense){
      Serial.println("pad1");  //Imprime pad detectado
     
      tmrpcm.play("hhat.wav");  // nombre de archivo a reproducir guardado en la sd.
      delay(tiempo);} 
             ////////////////FFFFFFFFFFFFFFFFFFF//////////////////////////
  long valor2 =  cs_14_3.capacitiveSensor(20);
 
 if (valor2 > sense){
      Serial.println("pad2");  
     
     
    tmrpcm.play("plati1.wav");    
      delay(tiempo);} 
             ////////////////FFFFFFFFFFFFFFFFFFF//////////////////////////
  long valor3 =  cs_14_4.capacitiveSensor(20);
 
 if (valor3 > sense){
      Serial.println("pad3"); 
      tmrpcm.play("plati2.wav");    
      delay(100);} 
             ////////////////FFFFFFFFFFFFFFFFFFF//////////////////////////
  long valor4 =  cs_14_5.capacitiveSensor(20);
 
 if (valor4 > sense){
      Serial.println("pad4");  
     tmrpcm.play("tambor1.wav");    
      delay(100);} 
             ////////////////FFFFFFFFFFFFFFFFFFF//////////////////////////
  long valor5 =  cs_14_6.capacitiveSensor(20);
 
 if (valor5 > sense){
      Serial.println("pad5"); 
     tmrpcm.play("tambor2.wav");    
      delay(100);} 
             ////////////////FFFFFFFFFFFFFFFFFFF//////////////////////////
  long valor6 =  cs_14_7.capacitiveSensor(20);
 
 if (valor6 > sense){
      Serial.println("pad6"); 
     tmrpcm.play("go.wav");    
      delay(100);}
             ////////////////FFFFFFFFFFFFFFFFFFF//////////////////////////
  long valor7 =  cs_14_8.capacitiveSensor(20);
 
 if (valor7 > sense){
      Serial.println("pad7");  
      tmrpcm.play("bombo1.wav");    
      delay(100);} 
             ////////////////FFFFFFFFFFFFFFFFFFF//////////////////////////

what is here wrong

here wrong it is hijack a post to do.

Start your own thread.
But before that you do read How to use this forum

Grumpy_Mike:
here wrong it is hijack a post to do.

Start your own thread.
But before that you do read How to use this forum

where can I do this post?

In this section.