Go Down

Topic: Improve code with midi potentiometer adding analog button for midi control (Read 493 times) previous topic - next topic

djinn89

hi there!! Maybe someone can help me to improve the follow code adding 12 midi sending button
this is the code:

Code: [Select]
//#include <MIDI.h>
#include <MIDI.h>

#define numPots 6  // numer of pots
#define b 1        // this is the delta needed in

unsigned int currentPot[6] = {0,0,0,0,0,0};   
unsigned int pot[6] = {0,0,0,0,0,0};
byte controlChange = 0xBC; //0xB0 or 176

void setup() {
  MIDI.begin(4);
  // 115200 hairless MIDI
  Serial.begin(115200);
     }
     
 
void loop() {
  for(unsigned char i=0; i<numPots; i++) {
    currentPot[i] = analogRead(i) / 8;   
    if(abs(currentPot[i]-pot[i]) > b) {
      sendMidi(controlChange, i+1, currentPot[i]);
      pot[i] = currentPot[i];
    }
  }
}

void sendMidi(byte controlChange, unsigned int controlNum, int val) {
//MIDI.sendControlChange(controlNum, val);

Serial.write(controlChange);
Serial.write(controlNum);
Serial.write(val);
  // Serial.write(unsigned char(controlChange));
  //   Serial.write(unsigned char(controlNum));
  //     Serial.write(unsigned char(val));
  }


I don't know anything about arduino code so if someone can help me... I can learn something new
Thanks
Luca ;)

marco_c

It is not clear what you want to do:

1. How are the buttons wired up?
2. What do you want the buttons to do?
Arduino libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

Go Up