Thanks to PieterP turning me onto his Control Surface library yesterday, I've been able to streamline the code for my MCS. I have multiple buttons, pots and mux pots all working. I even have an LED indicator that turns off and on with a button press. I would love to add more LED's for other buttons, but I haven't been able to figure out how. I know I'm missing something completely obvious. This is the LED button press example code I used from the Control Surface library.
// Include the library
#include <Arduino_Helpers.h>
#include <AH/Hardware/Button.hpp>
// Create a Button object that reads a push button connected to pin 2:
Button pushbutton = {2};
// The pin with the LED connected:
const pin_t ledPin = LED_BUILTIN;
void setup() {
pinMode(ledPin, OUTPUT);
pushbutton.begin();
// You can invert the input, for use with normally closed (NC) switches:
// pushbutton.invert();
}
void loop() {
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);
}
}