Potentiometer not working


i have problem midi controller, buttons , potmeters not working, when link in fl studio knob in fl studio goes crasy, when remove al code potmeters buttons work, think code.
i'm using teensy 3.2 board, here photo's of midi controller:

https://gyazo.com/c1131d35b44265fe43ce54f8d9a07b2a
https://gyazo.com/2552fe139b6727e987fb19ded26578d7
https://gyazo.com/ec559702097031901fcc5c3559b6d796

i have 2 potmeters , 2 buttons ,my potmeters on pin 23 , 22 here's code(i got code djtechtools):

#include <bounce.h>

// define how many pots active number of available analog inputs
#define analoginputs 2
// make arrays input values , lagged input values
int inputanalog[2];
int ialag[2];
// make array of cc values
int ccvalue[2];
// index variable loop
int i;

// cc values buttons
int cc_off = 0;
int cc_on = 65;
int cc_super = 127;

// map buttons cc button
int cc0 = 51;
int cc1 = 52;

bounce button0 = bounce(0, 1);
bounce button1 = bounce(1, 1);

void setup() {
  // midi rate
  serial.begin(31250);
  pinmode(0, input_pullup);
  pinmode(1, input_pullup);
  pinmode(23, input_pullup);
  pinmode(22, input_pullup);
}

void loop() {
  // loop trough active inputs knobs
  (i=0;i<2;i++){
    // read current value @ i-th input
    inputanalog = analogread(i);
    // if magnitude of difference 8 or more...
    if (abs(inputanalog - ialag) > 7){
      // calc cc value based on raw value
      ccvalue = inputanalog/8;
      // send midi
      usbmidi.sendcontrolchange(i, ccvalue, 3);
      // set raw reading lagged array next comparison
      ialag = inputanalog;
    }
  delay(5); // limits midi messages reasonable number
  }
 
  // push button code
  button0.update();
  button1.update();

 
   if (button0.fallingedge())
  {
    usbmidi.sendcontrolchange(cc0, cc_on, 3);
  }
  if (button1.fallingedge())
  {
    usbmidi.sendcontrolchange(cc1, cc_on, 3);
  }
   
  if (button0.risingedge())
  {
    usbmidi.sendcontrolchange(cc0, cc_off, 3);
  }
  if (button1.risingedge())
  {

    usbmidi.sendcontrolchange(cc1, cc_off, 3);
  }
 
}


i appreciate help, thanks

you pots hooked 22 , 23.  analog inputs?  board talking about.

either way, hooked 22 , 23, when analog read in loop use 0 , 1. 


Arduino Forum > Using Arduino > Project Guidance > Potentiometer not working


arduino

Comments