I have a problem with my midi controller, the buttons and potmeters are not working, when I link something in fl studio than the knob in fl studio goes crasy, when I remove al the code for the potmeters the buttons does work, so I think its the code.
I'm using an teensy 3.2 board, here are some photo's of my midi controller:
I have two potmeters and two buttons ,my potmeters are on pin 23 and 22 here's my code(I got the code from djtechtools):
#include <Bounce.h>
// define how many pots are active up to number of available analog inputs
#define analogInputs 2
// make arrays for input values and lagged input values
int inputAnalog[2];
int iAlag[2];
// make array of cc values
int ccValue[2];
// index variable for loop
int i;
// cc values for buttons
int cc_off = 0;
int cc_on = 65;
int cc_super = 127;
// map buttons to cc for 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 for knobs
for (i=0;i<2;i++){
// read current value at i-th input
inputAnalog = analogRead(i);
- // if magnitude of difference is 8 or more...*
if (abs(inputAnalog - iAlag*) > 7){*
* // calc the CC value based on the raw value*
ccValue = inputAnalog*/8;*
* // send the MIDI*
_ usbMIDI.sendControlChange(i, ccValue*, 3);
// set raw reading to lagged array for next comparison*
iAlag = inputAnalog*;*
* }
delay(5); // limits MIDI messages to 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 would appreciate your help, thanks