Everything is currently 'working'. All the buttons, encoders, banks, and potentiometers work as expected. However each potentiometer only has about 75% usfull range. They still output 0-7F in the midi debug, but the last 25% of the pots and faders do nothing.
I was able to implement the potentiometer mapping and tired it on one potentiometer, but i was only able to limit its range even further, not expand it.
I measured the voltage on the wiper of the potentiometers and they do have a nice smooth range all the way through. (full output is within .1 of VCC of the multiplexers. 4.9vdc)
Is there a way to serial read the potentiometers within this code to read their value?
Any help on this would be great... here is the code messy and unfinished.
define USE_ROTARY_ENCODER
include // new line
include
include "MIDIcontroller.h"
byte MIDIchannel = 5;
const int numled = 40;
const int pin = 5;
byte drawingMemory[numled 3]; // 3 bytes per LED
DMAMEM byte displayMemory[numled 12]; // 12 bytes per LED
WS2812Serial leds(numled, displayMemory, drawingMemory, pin, WS2812_GRB);
define RED 0x001600 //ADJUSTED FOR ADAFRUIT DIFFUSED NEOPIXLES (RED AND GREEN ARE SWAPPED) (night mode)
define GREEN 0x160000
define BLUE 0x000016
define YELLOW 0x141000
define PURPLE 0x001616
define ORANGE 0x041000
define WHITE 0x101010
define AQUA 0x160016
//#define RED 0x00FF00 //ADJUSTED FOR ADAFRUIT DIFFUSED NEOPIXLES (RED AND GREEN ARE SWAPPED) (day mode)
//#define GREEN 0xFF0000
//#define BLUE 0x0000FF
//#define YELLOW 0xFFFF00
//#define PURPLE 0x00FFFF
//#define ORANGE 0xE05800
//#define WHITE 0xFFFFFF
//#define AQUA 0xFF00FF
int touchRead_pin_1 = 32;
int touchRead_pin_2 = 33;
int thresh = 2300;
int play_flag_1 = 0;
int play_flag_2 = 0;
int current_1;
int current_2;
int delay_time =3;
const int speedMultiply = 1; // No change in speed of the encoder (number of steps is multiplied by 1)
// THESE WERE THE VALUES//
const uint8_t velocity = 0b1111111; // Maximum velocity (0b1111111 = 0x7F = 127)
const uint8_t C2 = 36; // Name Desired pitches and define with MIDI value
const uint8_t D2 = 38;
const uint8_t E2 = 40;
const uint8_t f2 = 41;
const uint8_t G2 = 43;
const uint8_t a2 = 45;
const uint8_t B2 = 47;
const uint8_t C3 = 48;
const static size_t analogAverage = 16; // Use the average of 8 samples to get smooth transitions and prevent noise
const int minimumValue = 3; // the analog value read when the potentiometer is in the minimum position.
const int maximumValue = 1023; // the analog value read when the potentiometer is in the maximum position.
int mapCalibrated(int value) {
value = constrain(value, minimumValue, maximumValue); // make sure that the analog value is between the minimum and maximum value
return map(value, minimumValue, maximumValue, 0, 1023); // map the value from [minimumValue, maximumValue] to [0, 1023]
}
USBDebugMIDI_Interface midiInterface(115200);
// Create an instance of 'AnalogMultiplex' with the output pin of the multiplexer connected to
// analog input pin A0 and the address pins connected to pins 2, 3 and 4.
AnalogMultiplex multiplexer1(24, { 2, 3, 4 } );
AnalogMultiplex multiplexer2(25, { 2, 3, 4 } );
AnalogMultiplex multiplexer3(26, { 2, 3, 4 } );
AnalogMultiplex multiplexer4(27, { 2, 3, 4 } );
AnalogMultiplex multiplexer5(28, { 2, 3, 4 } );
AnalogMultiplex multiplexer6(A18, { 2, 3, 4 } );
AnalogMultiplex multiplexer7(A19, { 2, 3, 4 } );
AnalogMultiplex multiplexer8(A20, { 2, 3, 4 } );
//AnalogMultiplex multiplexer9(A12, { 2, 3, 4 } );
//AnalogMultiplex multiplexer10(A13, { 2, 3, 4 } );
Bank bank(4);
Bank bank2(4);
Bank bank3(8);
Bank bank4(8);
potentiometers1[0].map(mapCalibrated); // apply the 'mapCalibrated' function on the analog input of 'potentiometer'
potentiometers2[0].map(mapCalibrated);
Fixed!
Teensy 3.1 is only 3.3v tolerant on the analog lines, so the internal ADC was limiting.
Moved all potentiometers to the 3.3v bus and it works now !!
Everything is currently 'working'. All the buttons, encoders, banks, and potentiometers work as expected. However each potentiometer only has about 75% usfull range. They still output 0-7F in the midi debug, but the last 25% of the pots and faders do nothing. I was able to implement the potentiometer mapping and tired it on one potentiometer, but i was only able to limit its range even further, not expand it. I measured the voltage on the wiper of the potentiometers and they do have a nice smooth range all the way through. (full output is within .1 of VCC of the multiplexers. 4.9vdc) Is there a way to serial read the potentiometers within this code to read their value?
Any help on this would be great... here is the code messy and unfinished.
define USE_ROTARY_ENCODER
include // new line
include
include "MIDIcontroller.h"
byte MIDIchannel = 5; const int numled = 40; const int pin = 5; byte drawingMemory[numled 3]; // 3 bytes per LED DMAMEM byte displayMemory[numled 12]; // 12 bytes per LED WS2812Serial leds(numled, displayMemory, drawingMemory, pin, WS2812_GRB);
define RED 0x001600 //ADJUSTED FOR ADAFRUIT DIFFUSED NEOPIXLES (RED AND GREEN ARE SWAPPED) (night mode)
define GREEN 0x160000
define BLUE 0x000016
define YELLOW 0x141000
define PURPLE 0x001616
define ORANGE 0x041000
define WHITE 0x101010
define AQUA 0x160016
//#define RED 0x00FF00 //ADJUSTED FOR ADAFRUIT DIFFUSED NEOPIXLES (RED AND GREEN ARE SWAPPED) (day mode) //#define GREEN 0xFF0000 //#define BLUE 0x0000FF //#define YELLOW 0xFFFF00 //#define PURPLE 0x00FFFF //#define ORANGE 0xE05800 //#define WHITE 0xFFFFFF //#define AQUA 0xFF00FF
int touchRead_pin_1 = 32; int touchRead_pin_2 = 33; int thresh = 2300; int play_flag_1 = 0; int play_flag_2 = 0; int current_1; int current_2; int delay_time =3;
const int speedMultiply = 1; // No change in speed of the encoder (number of steps is multiplied by 1)
// THESE WERE THE VALUES// const uint8_t velocity = 0b1111111; // Maximum velocity (0b1111111 = 0x7F = 127) const uint8_t C2 = 36; // Name Desired pitches and define with MIDI value const uint8_t D2 = 38; const uint8_t E2 = 40; const uint8_t f2 = 41; const uint8_t G2 = 43; const uint8_t a2 = 45; const uint8_t B2 = 47; const uint8_t C3 = 48;
//const uint8_t C2 = 24; // Name Desired pitches and define with MIDI value //const uint8_t D2 = 26; //const uint8_t E2 = 28; //const uint8_t C1 = 18; //const uint8_t C3 = 30; //const uint8_t C5 = 48; //const uint8_t C6 = 54; //const uint8_t C7 = 60; //const uint8_t B8 = 77; //const uint8_t B0 = 17; //const uint8_t B1 = 23; //const uint8_t B4 = 47; const uint8_t B5 = 53; //const uint8_t D3 = 32; //const uint8_t D6 = 56; //const uint8_t E3 = 34;
const static size_t analogAverage = 16; // Use the average of 8 samples to get smooth transitions and prevent noise
const int minimumValue = 3; // the analog value read when the potentiometer is in the minimum position. const int maximumValue = 1023; // the analog value read when the potentiometer is in the maximum position. int mapCalibrated(int value) { value = constrain(value, minimumValue, maximumValue); // make sure that the analog value is between the minimum and maximum value return map(value, minimumValue, maximumValue, 0, 1023); // map the value from [minimumValue, maximumValue] to [0, 1023] }
USBDebugMIDI_Interface midiInterface(115200);
// Create an instance of 'AnalogMultiplex' with the output pin of the multiplexer connected to // analog input pin A0 and the address pins connected to pins 2, 3 and 4. AnalogMultiplex multiplexer1(24, { 2, 3, 4 } ); AnalogMultiplex multiplexer2(25, { 2, 3, 4 } ); AnalogMultiplex multiplexer3(26, { 2, 3, 4 } ); AnalogMultiplex multiplexer4(27, { 2, 3, 4 } ); AnalogMultiplex multiplexer5(28, { 2, 3, 4 } ); AnalogMultiplex multiplexer6(A18, { 2, 3, 4 } ); AnalogMultiplex multiplexer7(A19, { 2, 3, 4 } ); AnalogMultiplex multiplexer8(A20, { 2, 3, 4 } ); //AnalogMultiplex multiplexer9(A12, { 2, 3, 4 } ); //AnalogMultiplex multiplexer10(A13, { 2, 3, 4 } );
Bank bank(4); Bank bank2(4); Bank bank3(8); Bank bank4(8);
BankSelector bankSelector(bank, { multiplexer4.pin(7) }, 4); BankSelector bankSelector2(bank2, { multiplexer1.pin(0) }, 4); BankSelector bankSelector3(bank3, { multiplexer2.pin(2) }, 8); BankSelector bankSelector4(bank4, { multiplexer2.pin(2) }, 8);
//Channel_Volume, Pan, Foot_Controller, Balance, can all have 16 inputs each for future reference. Analog potentiometers1[] = { {multiplexer6.pin(0), MIDI_CC::Channel_Volume, 1}, //RIGHT PITCH {multiplexer6.pin(1), MIDI_CC::Channel_Volume, 2}, //FX 2 A GAIN {multiplexer6.pin(2), MIDI_CC::Channel_Volume, 3}, //FX 1 MIX //{multiplexer6.pin(3), MIDI_CC::Channel_Volume, 4}, //BAD CHANNEL ? {multiplexer6.pin(4), MIDI_CC::Channel_Volume, 5}, //FX 1 B GAIN //{multiplexer6.pin(5), MIDI_CC::Channel_Volume, 6}, //OPEN {multiplexer6.pin(6), MIDI_CC::Channel_Volume, 7}, //LEFT MID //{multiplexer6.pin(7), MIDI_CC::Channel_Volume, 8}, //OPEN }; Analog potentiometers2[] = { {multiplexer7.pin(0), MIDI_CC::Foot_Controller, 1}, //LEFT HIGH {multiplexer7.pin(1), MIDI_CC::Foot_Controller, 2}, // FX 2 B GAIN {multiplexer7.pin(2), MIDI_CC::Foot_Controller, 3}, //LEFT PITCH {multiplexer7.pin(3), MIDI_CC::Foot_Controller, 4}, //X FADER {multiplexer7.pin(4), MIDI_CC::Foot_Controller, 5}, //LEFT FADER {multiplexer7.pin(5), MIDI_CC::Foot_Controller, 6}, // FX 2 MIX {multiplexer7.pin(6), MIDI_CC::Foot_Controller, 7}, //LEFT GAIN {multiplexer7.pin(7), MIDI_CC::Foot_Controller, 8}, //LEFT LOW }; Analog potentiometers3[] = { {multiplexer8.pin(0), MIDI_CC::Pan, 1}, //PHONE VOLUME {multiplexer8.pin(1), MIDI_CC::Pan, 2}, //PHONE MIX {multiplexer8.pin(2), MIDI_CC::Pan, 3}, // RIGHT HIGH {multiplexer8.pin(3), MIDI_CC::Pan, 4}, //RIGHT LOW {multiplexer8.pin(4), MIDI_CC::Pan, 5}, //RIGHT GAIN {multiplexer8.pin(5), MIDI_CC::Pan, 6}, //RIGHT MID {multiplexer8.pin(6), MIDI_CC::Pan, 7}, // FX 1 A GAIN {multiplexer8.pin(7), MIDI_CC::Pan, 8}, //RIGHT FADER
};
Digital Buttonslarge[] = { {multiplexer1.pin(0), C2, 1, velocity}, //L MODE SELECT {multiplexer1.pin(1), D2, 1, velocity}, //BUTTON 34 {multiplexer1.pin(2), E2, 1, velocity}, //FX 1 B SELECT //{multiplexer1.pin(3), f2, 1, velocity}, //BUTTON 37 //{multiplexer1.pin(4), G2, 1, velocity}, // BUTTON 39 //{multiplexer1.pin(5), a2, 1, velocity}, OPEN //{multiplexer1.pin(6), B2, 1, velocity}, // BUTTON 35 {multiplexer1.pin(7), C3, 1, velocity}, //BUTTON 36
{multiplexer2.pin(0), C2, 2, velocity}, // L KEY LOCK {multiplexer2.pin(1), D2, 2, velocity}, // FX 1 A SELECT {multiplexer2.pin(2), E2, 2, velocity}, //SAMPLER SELECT {multiplexer2.pin(3), f2, 2, velocity}, //RIGHT PFL {multiplexer2.pin(4), G2, 2, velocity}, // FX 2 A SELECT {multiplexer2.pin(5), a2, 2, velocity}, // BUTTON 32 {multiplexer2.pin(6), B2, 2, velocity}, // R KEY LOCK {multiplexer2.pin(7), C3, 2, velocity}, // FX 2 B SELECT
//{multiplexer3.pin(0), C2, 3, velocity}, //SAMPLER L,R, BOTH SELECT shorted with LIB PREV {multiplexer3.pin(1), D2, 3, velocity}, //BUTTON 2 //{multiplexer3.pin(2), E2, 3, velocity}, //BUTTON 33 {multiplexer3.pin(3), f2, 3, velocity}, //BUTTON 4 {multiplexer3.pin(4), B5, 3, velocity}, // LIBRABRY PREVIEW {multiplexer3.pin(5), a2, 3, velocity}, //BUTTON 38 {multiplexer3.pin(6), B2, 3, velocity}, // LIBRABRY STOP {multiplexer3.pin(7), C3, 3, velocity}, // LIBRABRY BACK
//{multiplexer4.pin(0), C2, 4, velocity}, //BUTTON 7 // {multiplexer4.pin(1), D2, 4, velocity}, //BUTTON 3 {multiplexer4.pin(2), E2, 4, velocity}, //BUTTON 0 {multiplexer4.pin(3), f2, 4, velocity}, // R CH LOAD {multiplexer4.pin(4), G2, 4, velocity}, // LEFT PFL //{multiplexer4.pin(5), a2, 4, velocity}, //BUTTON 5 //{multiplexer4.pin(6), B2, 4, velocity}, // SAMPLER LOAD, effecting button 0 :( was f2 {multiplexer4.pin(7), C3, 4, velocity}, //RIGHT MODE SELECT
{multiplexer5.pin(0), C2, 5, velocity}, //BUTTON 6 {multiplexer5.pin(1), D2, 5, velocity}, // L CH LOAD //{multiplexer5.pin(2), E2, 5, velocity}, // SAMPLER PFL {multiplexer5.pin(3), f2, 5, velocity}, //LIBRBARY FWD //{multiplexer5.pin(4), G2, 5, velocity}, //OPEM //{multiplexer5.pin(5), a2, 5, velocity}, //BUTTON 1 // {multiplexer5.pin(6), B2, 5, velocity}, //OPEN //{multiplexer5.pin(7), C3, 5, velocity}, //OPEN
};
Digital Buttonsright[] = { {multiplexer4.pin(0), C2, 4, velocity}, //BUTTON 7 {multiplexer4.pin(5), a2, 4, velocity}, //BUTTON 5 {multiplexer4.pin(1), D2, 4, velocity}, //BUTTON 3 {multiplexer5.pin(5), a2, 5, velocity}, //BUTTON 1 };
Digital Buttonsleft[] = { {multiplexer1.pin(4), G2, 1, velocity}, // BUTTON 39 {multiplexer1.pin(3), f2, 1, velocity}, //BUTTON 37 {multiplexer1.pin(6), B2, 1, velocity}, // BUTTON 35 {multiplexer3.pin(2), E2, 3, velocity}, //BUTTON 33 };
Digital Buttonssampler[] = { {multiplexer5.pin(2), E2, 5, velocity}, // SAMPLER PFL {multiplexer4.pin(6), B2, 4, velocity}, // SAMPLER LOAD {multiplexer3.pin(0), C2, 3, velocity}, //SAMPLER L,R, BOTH SELECT
};
RotaryEncoder enc = {0, 1, 0x2F, 17, speedMultiply, NORMAL_ENCODER}; //R JOG RotaryEncoder enc1 = {6, 7, 0x3F, 18, speedMultiply, NORMAL_ENCODER}; //L JOG RotaryEncoder enc2 = {9, 10, 0x4F, 19, speedMultiply, NORMAL_ENCODER}; // LIBRARY SCROLL RotaryEncoder enc3 = {11, 12, 0x5F, 20, speedMultiply, NORMAL_ENCODER}; //FX 1 B SELECT RotaryEncoder enc4 = {14, 15, 0x6F, 21, speedMultiply, NORMAL_ENCODER}; // SAMPLER VOL RotaryEncoder enc5 = {16, 17, 0x7F, 22, speedMultiply, NORMAL_ENCODER}; //FX 2 A SELECT RotaryEncoder enc6 = {18, 19, 0x8F, 23, speedMultiply, NORMAL_ENCODER}; //FX 2 B SELECT RotaryEncoder enc7 = {20, 21, 0x9F, 24, speedMultiply, NORMAL_ENCODER}; //FX 1 A SELECT
int counter = 0; int counter1 = 0;
void setup() {
bank.add(Buttonsright); bank2.add(Buttonsleft); bank3.add(Buttonssampler); bank4.add(enc4);
potentiometers1[0].map(mapCalibrated); // apply the 'mapCalibrated' function on the analog input of 'potentiometer' potentiometers2[0].map(mapCalibrated);
} void loop() {
MIDI_Controller.refresh();
int buttonState; buttonState = digitalRead(multiplexer4.pin(7)); if (buttonState == LOW) { counter++; delay(300); } else if (counter == 0) { leds.setPixel(1, BLUE); leds.setPixel(3, BLUE); leds.setPixel(5, BLUE); leds.setPixel(7, BLUE); leds.show(); } else if (counter == 1) { leds.setPixel(1, ORANGE); leds.setPixel(3, ORANGE); leds.setPixel(5, ORANGE); leds.setPixel(7, ORANGE); leds.show(); } else if (counter == 2) { leds.setPixel(1, GREEN); leds.setPixel(3, GREEN); leds.setPixel(5, GREEN); leds.setPixel(7, GREEN); leds.show(); } else if (counter == 3) { leds.setPixel(1, PURPLE); leds.setPixel(3, PURPLE); leds.setPixel(5, PURPLE); leds.setPixel(7, PURPLE); leds.show(); } else { counter = 0; }
int buttonState1; buttonState1 = digitalRead(multiplexer1.pin(0)); if (buttonState1 == LOW) { counter1++; delay(300); } else if (counter1 == 0) { leds.setPixel(33, BLUE); leds.setPixel(35, BLUE); leds.setPixel(37, BLUE); leds.setPixel(39, BLUE); leds.show(); } else if (counter1 == 1) { leds.setPixel(33, ORANGE); leds.setPixel(35, ORANGE); leds.setPixel(37, ORANGE); leds.setPixel(39, ORANGE); leds.show(); } else if (counter1 == 2) { leds.setPixel(33, GREEN); leds.setPixel(35, GREEN); leds.setPixel(37, GREEN); leds.setPixel(39, GREEN); leds.show(); } else if (counter1 == 3) { leds.setPixel(33, PURPLE); leds.setPixel(35, PURPLE); leds.setPixel(37, PURPLE); leds.setPixel(39, PURPLE); leds.show(); } else { counter1 = 0; }
current_1 = touchRead(touchRead_pin_1); if(current_1 > thresh && play_flag_1 == 0) { play_flag_1 = 1; usbMIDI.sendNoteOn(60, 127, 1); delay(delay_time); }
if(current_1 < thresh && play_flag_1 == 1) { play_flag_1 = 0; usbMIDI.sendNoteOff(60, 0, 1); delay(delay_time); } current_2 = touchRead(touchRead_pin_2); if(current_2 > thresh && play_flag_2 == 0) { play_flag_2 = 1; usbMIDI.sendNoteOn(62, 127, 1); delay(delay_time); } if(current_2 < thresh && play_flag_2 == 1) { play_flag_2 = 0; usbMIDI.sendNoteOff(62, 0, 1); delay(delay_time); }
//int buttonState; //buttonState = digitalRead(multiplexer4.pin(7));
//switch (buttonState) { // delay (100); // case 0: // leds.setPixel(0, RED); //leds.setPixel(1, RED); //leds.setPixel(2, RED); //leds.setPixel(3, RED); //leds.show(); // break; //case 1: // leds.setPixel(0, GREEN); //leds.setPixel(1, GREEN); // leds.setPixel(2, GREEN); //leds.setPixel(3, GREEN); //leds.show(); // break; //case 2: //leds.setPixel(0, PURPLE); // leds.setPixel(1, PURPLE); // leds.setPixel(2, PURPLE); // leds.setPixel(3, PURPLE); // leds.show(); // break; //default : // leds.setPixel(0, BLUE); //leds.setPixel(1, BLUE); // leds.setPixel(2, BLUE); // leds.setPixel(3, BLUE); // leds.show(); // break;
// }
}