Hello everybody! I´m new in the site
I´m actually making a MIDI controller with an arduino micro. I´d like to connect a 4x4 keypad to send MIDI notes.
My idea is to connect the keypad trough a 16 channel multiplexer (HC4067) but here is the problem:
When I connect the keypad directly to arduino pins it works perfectly, but when I modify the code to work with the mux, it doesn´t.
My question is if it´s posible to use the keypad wired to a mux.
Here is the code for the mux:
#include <Arduino.h>
#include "Mux.h"
using namespace admux;
/*
* Creates a Mux instance.
*
* 1st argument is the SIG (signal) pin (Arduino digital input pin 3).
* 2nd argument is the S0-S3 (channel control) pins (Arduino pins 8, 9, 10, 11).
*/
Mux mux(Pin(9, INPUT_PULLUP, PinType::Digital), Pinset(5, 6, 7, 8));
void setup() {
// Serial port initialization.
Serial.begin(9600); while (!Serial) /* Waits for serial port to connect (needed for Leonardo only) */;
}
/**
* Reads the 16 channels and reports on the serial monitor if the corresponding
* push button is pressed.
*/
void loop() {
byte data;
for (byte i = 0; i < mux.channelCount(); i++) {
data = mux.read(i) /* Reads from channel i (returns HIGH or LOW) */;
Serial.print("Push button at channel "); Serial.print(i); Serial.print(" is "); Serial.println(data == LOW ? "pressed" : "not pressed");
}
Serial.println();
delay(1500);
}
I would like to know if what I want to do is really possible.
Beyond what was previously mentioned, the idea of the project is to use two multiplexers: one to control potentiometers (which is already working) and another multiplexer for digital inputs.
Thanks!!

