Control Surface CD74HC4067 for LEDs and Buttons

Hello,

I'm using the Control Surface library and using a CD74HC4067 MUX. When I mix LEDs and buttons, the buttons are working but not the LEDs. When I plug them directly in the Pro Micro, everything work. Any idea why the LEDs don't light up?

Thanks.

 
#include <Control_Surface.h>

USBMIDI_Interface usbmidi;

template <class T, size_t N> constexpr size_t len(const T (&)[N]) { return N; }

//************************************* MUX 1 ************************************************
//******************** Instantiate 74HC4067 Digital multiplexer ******************************
//Digital input pin 1, Address pins S0, S1, S2, S3
CD74HC4067 mux1 ={1, {0, 2, 3, 5} };

CCButton buttons1 [] = {
{ mux1.pin(15), {21, CHANNEL_1 } },  // SEL 2
{ mux1.pin(13), {20, CHANNEL_1 } },  // REC 2 
{7, {22, CHANNEL_1}}, // Mute 1 
};

pin_t leds1 [] {
mux1.pin(14), 
mux1.pin(12), 
6,
};


//*********************************** FADERS & POTS ******************************************
CCPotentiometer knobsTop [] {
  {A0, {0x24, CHANNEL_1}}, // FADER 1
  {A1, {0x25, CHANNEL_2}}, // FADER 2
};

BitArray<len(leds1)> led_states1;

static_assert(len(leds1) == len(buttons1), "");

void setup() {
  Control_Surface.begin();
 for (auto led1 : leds1)
    pinMode(led1, OUTPUT);
 }

void loop() { // Refresh all inputs
  Control_Surface.loop();
  for (size_t i = 0; i < len(buttons1); ++i) {
    if (buttons1[i].getButtonState() == Button::Falling) {
      bool new_state1 = !led_states1.get(i);
      digitalWrite(leds1[i], new_state1 ? HIGH : LOW);
      led_states1.set(i, new_state1);
    }
  }
}

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