Go Down

Topic: Control Surface library CCValueLED (Read 450 times) previous topic - next topic


Want Midi input to turn on/off relay with CC message. I found the CCValueLED Class Reference page in the impressive Control Surface library. https://tttapa.github.io/Control-Surface-doc/Doxygen/da/d34/classCCValueLED.html  This is probably exactly what Im looking for. But need some help with example how to use it.  ::)   How would you write code for something like this?

Incoming data

CC80, 127 relay_1 ON
CC80, 0 relay_1 OFF

CC81, 127 relay_2 ON
CC81, 0 relay_2 OFF

and so on..



You can start from the NoteValueLED example.

As you can see from the documentation, CCValueLED and NoteValueLED are pretty much equivalent, so the code would be:
#include <Control_Surface.h> // Include the Control Surface library

// Instantiate a MIDI over USB interface.
USBMIDI_Interface midi;
// Instantiate the LED that will light up when the value of CC80 is > 0
CCValueLED led = {
  LED_BUILTIN,     // Pin of built-in LED
  {80, CHANNEL_1}, // CC Controller #80 on MIDI channel 1
void setup() {
  Control_Surface.begin(); // Initialize Control Surface
void loop() {
  Control_Surface.loop(); // Update the Control Surface

For multiple LEDs (or relays), you can use an array:
CCValueLED relays[] =   {
    {80, CHANNEL_1},
    {81, CHANNEL_1},



Pieter that works perfect. Amazing work you are doing with the Control Surface library. Thanks for your help

Go Up