Pages: [1]   Go Down
Author Topic: Improve code with midi potentiometer adding analog button for midi control  (Read 451 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
//#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 smiley-wink
Logged

Sydney, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1251
Big things come in large packages
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Pages: [1]   Go Up
Jump to: