MIDI - How to control 128 LEDs with Control-Surface.h?

Hello all,

after reading a lot this is my first post in this wonderfull forum.
I want to build a midi controller for vMix and for this I cannibalized an old Sony vision mixer panel and now have a T-bar and 64 buttons with two LEDs each. For now I use a Arduino Mega 2560 that will be replaced by a Teensy 4.1 later.

I am an absolute beginner in terms of Arduino and programming. With the Controlsurface Library I have managed the input-side wonderfully so far and would now like to implement the control of the LEDs.

//https://tttapa.github.io/Control-Surface-doc/Doxygen/d0/dcc/AbsoluteRotaryEncoder_8ino-example.html
//https://github.com/tttapa/Control-Surface/blob/master/examples/1.%20MIDI%20Output/2.%20Buttons%20%26%20Switches/1.%20Momentary%20Push%20Buttons/NoteButtonMatrix/NoteButtonMatrix.ino
//https://github.com/tttapa/Control-Surface/blob/master/src/MIDI_Outputs/CCAbsoluteEncoder.hpp

#include <Encoder.h> // Include the Encoder library.
#include <Control_Surface.h>

//USBMIDI_Interface midi;
HairlessMIDI_Interface midi;

// Instantiate a CCAbsoluteEncoder object
CCAbsoluteEncoder enc = {
  {2, 3},       // pins
  MIDI_CC::Pan, // MIDI address (CC number + optional channel)
  1,            // optional multiplier if the control isn't fast enough
  8,            // optional pulses per step
};
 
// The note numbers corresponding to the buttons in the matrix
const AddressMatrix<4, 4> addresses = {{
  {1, 2, 3, 4},
  {5, 6, 7, 8},
  {9, 10, 11, 12},
  {13, 14, 15, 16},
}};

NoteButtonMatrix<4, 4> buttonmatrix = {
  {38, 40, 42, 44}, // row pins
  {46, 48, 50, 52},    // column pins
  addresses,    // address matrix
  CHANNEL_1,    // channel and cable number
};

void setup() {
  Control_Surface.begin();
}

void loop() {
  Control_Surface.loop();
}

I can send note-on commands to the Arduino with vMix. However, I don't have enough pins for the 128 LEDs (64 buttons with two LEDs each). After some internet research I came across the MAX7219. Unfortunately, my programming skills are not sufficient for this (each LED should be controlled individually with a note-on or note-off command).

Can someone help me or point me into the right direction?
TIA, Flo

4x4_Keypad_Rotary.ino (1.23 KB)

I usually just use shift registers (4015 cmos) aka bitshifters. If i have more LEDS than pins.

Control Surface supports shift registers and MAX7219 LED drivers out of the box.

Have a look at the Getting Started guide, as well as the MAX7219-NoteLED.ino, Note-LED.ino and Note-Range-LEDs.ino examples.

For such a large number of LEDs and buttons, I'd highly recommend using the NoteRangeLEDs and NoteButtons classes instead of creating over a hundred separate instances of the NoteValueLED and NoteButton classes.

Pieter

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.