Hey,
i'm relativly new to the arduino cosmos but wanted to build a custom midi controller since i new it is possible.
Last week i got a Leonardo and some parts that i knew i want to use.
I allready accomplished some working sketches but now i have a problem (and google and the forum couldn't help me).
I use the awesome Control Surface Library.
I want to use a lot of buttons and encoders to control my DAW (Reaper and hopefully someday Pro Tools) and some Plugins.
I managed to get the buttons working with a multiplexer.
The Encoders, when i connect them each individually but not with a multiplexer. So first: is that even possible?
My try on this was as follows:
#include <Encoder.h>
#include "Control_Surface.h"
#include <MIDI_Outputs/CCRotaryEncoder.hpp>
#include <MIDI_Outputs/CCButton.hpp>
#include <MIDI_Interfaces/DebugMIDI_Interface.hpp>
USBMIDI_Interface midi;
//USBDebugMIDI_Interface midi = {115200};
const int speedMultiplier = 2;
CD74HC4051 muxB = { // mux for buttons
11, // digital input pin
{8, 9, 10} // Address pins S0, S1, S2
};
CD74HC4051 muxE1 = { // mux for encoder 1st pin
12, // digital input pin
{8, 9, 10} // Address pins S0, S1, S2
};
CD74HC4051 muxE2 = { // mux for encoder 2nd pin
13, // digital input pin
{8, 9, 10} // Address pins S0, S1, S2
};
CCButton Buttons [] = {
{muxB.pin(0), {8, CHANNEL_1}},
{muxB.pin(1), {9, CHANNEL_1}},
{muxB.pin(2), {10, CHANNEL_1}},
{muxB.pin(3), {11, CHANNEL_1}},
{muxB.pin(4), {12, CHANNEL_1}},
{muxB.pin(5), {13, CHANNEL_1}},
{muxB.pin(6), {14, CHANNEL_1}},
{muxB.pin(7), {15, CHANNEL_1}},
};
CCRotaryEncoder Encoders [] = {
{{muxE1.pin(0), muxE2.pin(0)}, {16, CHANNEL_1}, speedMultiplier, 1},
{{muxE1.pin(1), muxE2.pin(1)}, {17, CHANNEL_1}, speedMultiplier, 1},
{{muxE1.pin(2), muxE2.pin(2)}, {18, CHANNEL_1}, speedMultiplier, 1},
{{muxE1.pin(3), muxE2.pin(3)}, {19, CHANNEL_1}, speedMultiplier, 1},
{{muxE1.pin(4), muxE2.pin(4)}, {20, CHANNEL_1}, speedMultiplier, 1},
{{muxE1.pin(5), muxE2.pin(5)}, {21, CHANNEL_1}, speedMultiplier, 1},
{{muxE1.pin(6), muxE2.pin(6)}, {22, CHANNEL_1}, speedMultiplier, 1},
{{muxE1.pin(7), muxE2.pin(7)}, {23, CHANNEL_1}, speedMultiplier, 1},
};
void setup() {
RelativeCCSender::setMode(relativeCCmode::REAPER_RELATIVE_1);
Control_Surface.begin();
}
void loop() {
Control_Surface.loop();
}
I try to upload the curcuit so you can see what i patched.
I tried a lot of things (syntax like brackets, braces, less variables (speedmultiplier..) but nothing has worked.
I would to love to get some feedback and advice how to improve!
Again, i think i got a rough understanding of how to do stuff but i'm pretty new to the whole game.
This is the Code that i got working at the Moment with 8 buttons on one multiplexer and 5 encoders each conntected directly to the arduino (only five because i ran out of inputs, just learned today that the analog pins can also be used as digital pins..):
#include <Encoder.h>
#include "Control_Surface.h"
#include <MIDI_Outputs/CCRotaryEncoder.hpp>
#include <MIDI_Outputs/CCButton.hpp>
#include <MIDI_Interfaces/DebugMIDI_Interface.hpp>
USBMIDI_Interface midi;
//USBDebugMIDI_Interface midi = {115200};
const int speedMultiplier = 4;
const int speedMultiplier2 = 4;
int shift = 0;
CD74HC4051 muxB = { // mux for buttons
3, // digital input pin
{0, 1, 2} // Address pins S0, S1, S2
};
CCButton Buttons [] = {
{muxB.pin(0), {8, CHANNEL_1}},
{muxB.pin(1), {9, CHANNEL_1}},
{muxB.pin(2), {10, CHANNEL_1}},
{muxB.pin(3), {11, CHANNEL_1}},
{muxB.pin(4), {12, CHANNEL_1}},
{muxB.pin(5), {13, CHANNEL_1}},
{muxB.pin(6), {14, CHANNEL_1}},
{muxB.pin(7), {15, CHANNEL_1}},
};
CCRotaryEncoder enc1 = {
{4, 5}, // pins
{16, CHANNEL_1}, // address
speedMultiplier, // multiplier
1, // pulses per click
};
CCRotaryEncoder enc2 = {
{6, 7}, // pins
{17, CHANNEL_1}, // address
speedMultiplier, // multiplier
1, // pulses per click
};
CCRotaryEncoder enc3 = {
{8, 9}, // pins
{18, CHANNEL_1}, // address
speedMultiplier, // multiplier
1, // pulses per click
};
CCRotaryEncoder enc4 = {
{10, 11}, // pins
{19, CHANNEL_1}, // address
speedMultiplier, // multiplier
1, // pulses per click
};
CCRotaryEncoder enc5 = {
{12, 13}, // pins
{20, CHANNEL_1}, // address
speedMultiplier2, // multiplier
1, // pulses per click
};
void setup() {
RelativeCCSender::setMode(relativeCCmode::REAPER_RELATIVE_1);
Control_Surface.begin();
}
void loop() {
Control_Surface.loop();
}
thank you in advance!
