Been dabbling with the “Control Surface” Lib for Arduino. Wow its easy to use. Ive only scratched the surface, but yeah its really good. Way better than the default midi lib.
https://tttapa.github.io/Control-Surface-doc/Doxygen/d5/d7d/md_pages_Getting-Started.html#first-input
Some demo serial out messages from the USBDebugMIDI_Interface:
01:15:02.777 -> Control Change Channel: 2 Data 1: 0x07 Data 2: 0x40 Cable: 0
01:15:02.812 -> Control Change Channel: 2 Data 1: 0x07 Data 2: 0x42 Cable: 0
01:15:02.812 -> Control Change Channel: 2 Data 1: 0x07 Data 2: 0x43 Cable: 0
01:15:02.847 -> Control Change Channel: 2 Data 1: 0x07 Data 2: 0x44 Cable: 0
01:15:03.092 -> Control Change Channel: 1 Data 1: 0x07 Data 2: 0x01 Cable: 0
01:15:03.127 -> Control Change Channel: 1 Data 1: 0x07 Data 2: 0x03 Cable: 0
01:15:03.127 -> Control Change Channel: 1 Data 1: 0x07 Data 2: 0x05 Cable: 0
01:15:03.127 -> Control Change Channel: 1 Data 1: 0x07 Data 2: 0x06 Cable: 0
01:15:03.162 -> Control Change Channel: 1 Data 1: 0x07 Data 2: 0x07 Cable: 0
01:15:03.301 -> Control Change Channel: 1 Data 1: 0x07 Data 2: 0x08 Cable: 0
01:15:11.537 -> Control Change Channel: 5 Data 1: 0x07 Data 2: 0x2d Cable: 0
I have tested with the 5 pin Midi din interface this has and its really as simple as swapping the interface init.
There is support for midi in/out and a lot of support for mux and shift registers. Also, many capabilities for visualizations with led and even OLED displays. Im just using the default lib for the LCD screen for output.
Im using the getValue() function of the CCPotentiometer object to pull back the value before display to the screen. This is just nuts how much of an abstraction layer this presents.
I also have a for loop within the loop() so to offset the screen draw. I wanted the screen to update less frequently so it doesnt dim/flicker as much, and i didnt want to have the midi interface updates be delayed as well.
//===============================================================================
// Header Files
//===============================================================================
#include <Control_Surface.h> // Include the Control Surface library
#include <LiquidCrystal.h>
// Initialize the LCD library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 5, en = 6, d4 = 7, d5 = 8, d6 = 9, d7 = 10;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// Instantiate a Serial MIDI interface at the default MIDI baud rate.
USBDebugMIDI_Interface midi = {115200};
AnalogMultiplex<4> mux = {
A0, // Analog input pin
{2,3,4} // Address pins S0, S1, S2
};
using namespace MIDI_Notes;
// 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 plus 2 other analog pins
CCPotentiometer volumePotentiometers[] = {
{mux.pin(0), {MIDI_CC::Channel_Volume, CHANNEL_5}},
{mux.pin(1), {MIDI_CC::Channel_Volume, CHANNEL_4}},
{mux.pin(2), {MIDI_CC::Channel_Volume, CHANNEL_3}},
{mux.pin(3), {MIDI_CC::Channel_Volume, CHANNEL_6}},
{mux.pin(4), {MIDI_CC::Channel_Volume, CHANNEL_1}},
{mux.pin(5), {MIDI_CC::Channel_Volume, CHANNEL_8}},
{mux.pin(6), {MIDI_CC::Channel_Volume, CHANNEL_2}},
{mux.pin(7), {MIDI_CC::Channel_Volume, CHANNEL_7}},
{A1, {MIDI_CC::Channel_Volume, CHANNEL_9}},
{A2, {MIDI_CC::Channel_Volume, CHANNEL_10}},
};
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
Control_Surface.begin(); // Initialize the Control Surface
}
void loop()
{
// For loop will have the control interface update i times for every screen refresh
for (int i = 0; i<=10; i++) {
Control_Surface.loop();
};
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
int pot_5_value = volumePotentiometers[0].getValue();
int pot_4_value = volumePotentiometers[1].getValue();
int pot_3_value = volumePotentiometers[2].getValue();
int pot_6_value = volumePotentiometers[3].getValue();
int pot_1_value = volumePotentiometers[4].getValue();
int pot_8_value = volumePotentiometers[5].getValue();
int pot_2_value = volumePotentiometers[6].getValue();
int pot_7_value = volumePotentiometers[7].getValue();
int pot_9_value = volumePotentiometers[8].getValue();
int pot_10_value = volumePotentiometers[9].getValue();
// Print the values of the pots in hex to the LCD screen.
lcd.setCursor(0,0);
lcd.print((char)124);
lcd.setCursor(1,0);
lcd.print(pot_1_value, HEX);
lcd.setCursor(3,0);
lcd.print((char)124);
lcd.setCursor(4,0);
lcd.print(pot_2_value, HEX);
lcd.setCursor(6,0);
lcd.print((char)124);
lcd.setCursor(7,0);
lcd.print(pot_3_value, HEX);
lcd.setCursor(9,0);
lcd.print((char)124);
lcd.setCursor(10,0);
lcd.print(pot_4_value, HEX);
lcd.setCursor(12,0);
lcd.print((char)124);
lcd.setCursor(13,0);
lcd.print(pot_5_value, HEX);
lcd.setCursor(15,0);
lcd.print((char)124);
lcd.setCursor(0,1);
lcd.print((char)124);
lcd.setCursor(1,1);
lcd.print(pot_6_value, HEX);
lcd.setCursor(3,1);
lcd.print((char)124);
lcd.setCursor(4,1);
lcd.print(pot_7_value, HEX);
lcd.setCursor(6,1);
lcd.print((char)124);
lcd.setCursor(7,1);
lcd.print(pot_8_value, HEX);
lcd.setCursor(9,1);
lcd.print((char)124);
lcd.setCursor(10,1);
lcd.print(pot_9_value, HEX);
lcd.setCursor(12,1);
lcd.print((char)124);
lcd.setCursor(13,1);
lcd.print(pot_10_value, HEX);
lcd.setCursor(15,1);
lcd.print((char)124);
}
Oh thats a 74HC4051 8 channel multiplexer btw:
https://www.taydaelectronics.com/cd74hc4051-74hc4051-744051-ic-8-channel-analog-multiplexer.html