Hi hopefully someone can see this.
Making a footswitch midi , as of now all the codes are working , however I need to assign corresponding LEDS to all of the switches.
The code is all working, only problem is the LED code is only working for one switch which is button 2 with the matching LED that toggles on and off indicator.
I would like to duplicate the effect to other buttons/switches with the same LED function I cannot see any examples on how to assign the said LED functions to other remaining switch.
#include <Control_Surface.h> // Include the Control Surface library
#include <Arduino_Helpers.h>
#include <AH/Hardware/Button.hpp>
USBMIDI_Interface midi;
// BUTTONS //
NoteButton button [] {
{2, {MIDI_Notes::C(4), CHANNEL_1} }, // pin // Note C4 on MIDI channel 1
{3, {MIDI_Notes::Db(4), CHANNEL_1} }, // pin // Note C4 on MIDI channel 1
{4, {MIDI_Notes::D(4), CHANNEL_1} }, // pin // Note C4 on MIDI channel 1
{5, {MIDI_Notes::Eb(4), CHANNEL_1} }, // pin // Note C4 on MIDI channel 1
{6, {MIDI_Notes::E(4), CHANNEL_1} }, // pin // Note C4 on MIDI channel 1
{7, {MIDI_Notes::F_(4), CHANNEL_1} }, // pin // Note C4 on MIDI channel 1
};
// LED INDICATOR PER SWITCH//
Button pushbutton
{2};
pin_t ledPin = 10;
// how do I duplicate this command to other swithces?//
void setup() {
Control_Surface.begin(); // Initialize Control Surface
//led void//
pinMode(ledPin, OUTPUT);
pushbutton.begin();
// You can invert the input, for use with normally closed (NC) switches:
// pushbutton.invert();
}
void loop() {
Control_Surface.loop(); // Update the Control Surface
//led void//
static bool ledState = LOW;
// Read the digital input, debounce the signal, and check the state of
// the button:
if (pushbutton.update() == Button::Falling) {
ledState = !ledState; // Invert the state of the LED
// Update the LED with the new state
digitalWrite(ledPin, ledState ? HIGH : LOW);
}
}