Hello,
I use the wonderful "Control Surface" software to create midi controllers and everything works fine so far. But now I have a module that needs more than eight buttons and I don't know how to do that. So far, based on the following example from the Control Surface website:
Control Surface: CCButton.ino, I have adapted the programmes by copying and adapting the text lines according to the required number of buttons.
#include <Control_Surface.h> // Include the Control Surface library
// Instantiate a MIDI over USB interface.
USBMIDI_Interface midi;
// Instantiate a CCButton object
CCButton button {
// Push button on pin 5:
5,
// General Purpose Controller #1 on MIDI channel 1:
{MIDI_CC::General_Purpose_Controller_1, CHANNEL_1},
};
void setup() {
Control_Surface.begin(); // Initialize Control Surface
}
void loop() {
Control_Surface.loop(); // Update the Control Surface
}
However, this no longer works for more than eight buttons because there are not more than eight General_Purpose_Controller_x. I think that this should generally be done differently, perhaps with an array? However, my knowledge is not such that I can cope with this alone.
I would be grateful for any help.
Here is my current source code for four buttons:
#include <Control_Surface.h> // Include the Control Surface library
// Instantiate a MIDI over USB interface.
USBMIDI_Interface midi;
// Instantiate a CCButton object
CCButton button1{
6,
// General Purpose Controller #1 on MIDI channel 1:
{MIDI_CC::General_Purpose_Controller_1, CHANNEL_1},
};
// Instantiate a CCButton object
CCButton button2{
7,
//General Purpose Controller #1 on MIDI channel 1:
{MIDI_CC::General_Purpose_Controller_2, CHANNEL_1},
};
// Instantiate a CCButton object
CCButton button3{
8,
// General Purpose Controller #1 on MIDI channel 1:
{MIDI_CC::General_Purpose_Controller_3, CHANNEL_1},
};
// Instantiate a CCButton object
CCButton button4{
9,
//General Purpose Controller #1 on MIDI channel 1:
{MIDI_CC::General_Purpose_Controller_4, CHANNEL_1},
};
// Instantiate a CCPotentiometer object
//CCPotentiometer potentiometer1 {
//A0, // Analog pin connected to potentiometer
//{26, CHANNEL_9}, // Channel volume of channel 1
//};
// Instantiate a CCPotentiometer object
//CCPotentiometer potentiometer2 {
//A1, // Analog pin connected to potentiometer
//{27, CHANNEL_10}, // Channel volume of channel 1
//};
// Instantiate an analog multiplexer
//CD74HC4051 mux {
//A2, // Analog input pin
//{10, 11, 12} // Address pins S0, S1, S2
//};
// Create an array of potentiometers that send out
// MIDI Control Change messages when you turn the
// potentiometers connected to the eight input pins of
// the multiplexer MIDIAddress myAddress = 16;
//CCPotentiometer volumePotentiometers[] {
//{mux.pin(0), {1 , CHANNEL_1}},
//{mux.pin(1), {2 , CHANNEL_2}},
//{mux.pin(2), {3 , CHANNEL_3}},
//{mux.pin(3), {4 , CHANNEL_4}},
//{mux.pin(4), {5 , CHANNEL_5}},
//{mux.pin(5), {6 , CHANNEL_6}},
//{mux.pin(6), {7 , CHANNEL_7}},
//{mux.pin(7), {8 , CHANNEL_8}},
//};
void setup() {
Control_Surface.begin(); // Initialize Control Surface
}
void loop() {
Control_Surface.loop(); // Update the Control Surface
}