SOLVED - Control Surface with LED

Recently I found a MIDI Controller Library by Mr Pieter and has doing Great Project using it. And I He makes Control Surface Library Too and I plan To build a Controller based on it

My problem is I want to add Lights (LEDs) for a specific button, such as if I press button, a LED will light up, if I pressed again the led is turn off. But no examples how to do it on the library

The code is :

#include <Control_Surface.h>


const uint8_t velocity = 0b1111111;
const uint8_t C4 = 60; on


Digital button1(2, C4, 1, velocity);
Digital button2(3, C4+1, 1, velocity);
void setup() {}

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

Please help me and thank you before

The library is not ready yet. There are no examples yet.

Pieter

PieterP:
The library is not ready yet. There are no examples yet.

Pieter

I counted 14 of them, in the examples folder.

These are just examples from the MIDI Controller library that were copied over.

PieterP:
The library is not ready yet. There are no examples yet.

Pieter

Oh, okay. I'll wait for that. Thank you

You can always check the header files to see how to use a library. You need the MIDI_LED or MIDI_Input_Note_Buffer classes.

For example:

Code:





```
#include <Control_Surface.h>

const uint8_t velocity = 0b1111111;
const uint8_t C4 = 60;

Digital button1(2, C4, 1, velocity);
Digital button2(3, C4+1, 1, velocity);

MIDI_LED led1(12, C4, 1); // LED on pin 12, note C4, channel 1
MIDI_LED led2(13, C4+1, 1);

void setupcolor=#000000[/color] {}

void loopcolor=#000000[/color] {
 Control_Surface.refreshcolor=#000000[/color];
}
```

|

There are definitely going to be some large API changes in the future.

Pieter

Thank You Mr Pieter. Sorry for my late respond. It Works Great. And I can add more inputs using the MCU List (your latest update).

You Are ROCK!

For the limitation of pin board, Cant wait for the Final Release with MIDI In / LED Multiplexer examples

The Latest update is Solved my problem. Instead Using Multiplexer, Its better using Shift Registers (see the example 15). Thank You Mr Pieter. You are Awesome!

Mr Pieter Is ROCK! He also help me on many projects. Here is a code I got from Mr Pieter if you want to use it for MIDI out with multiplexer

#include <MIDI_Controller.h> // Include the library

const pin_t muxPin = 5;

AnalogMultiplex multiplexer(muxPin, { 2, 3, 4 } );

Digital buttons[] = {
  {multiplexer.pin(0), 0x10, 1},
  {multiplexer.pin(1), 0x10, 2},
  {multiplexer.pin(2), 0x10, 3},
  {multiplexer.pin(3), 0x10, 4},
  {multiplexer.pin(4), 0x10, 5},
  {multiplexer.pin(5), 0x10, 6},
  {multiplexer.pin(6), 0x10, 7},
  {multiplexer.pin(7), 0x10, 8}
};

void setup() {
  ::pinMode(muxPin, INPUT_PULLUP);
}

void loop() {
  MIDI_Controller.refresh();
}

I dont know if its work with Control Surface Library. But its Working great on MIDI_Controller Library.