Here is my setup for converting an old electric organ into a midi controller. The last time I did anything with arduino was years ago at some computing day camp.
Below is the fritzing diagram that I made that shows how I have it wired up. I tried this setup without the multiplexer earlier, just attachting the leads to the analog pins and the ground rail to ground, and it worked perfectly (although with a noticable lag).
Now I can't seem to get a response from the MUX at all. I've tried taking all of the wires out and putting them back in multiple times, I swapped my headers for the boards. What am I doing wrong?
The only thing I can think of is that the headers may be loose. I salvaged a couple of them from the organ because I ran out of new ones.
Here is my fritzting diagram
and here is my code:
const int muxS0 = 0;
const int muxS1 = 1;
const int muxS2 = 2;
const int muxS3 = 3;
const int muxSIG = A1;
const int numKeys = 15;
const int baseNote = 39;
bool lastState[numKeys];
void setup() {
pinMode(muxS0, OUTPUT);
pinMode(muxS1, OUTPUT);
pinMode(muxS2, OUTPUT);
pinMode(muxS3, OUTPUT);
pinMode(muxSIG, INPUT_PULLUP);
usbMIDI.begin();
}
void selectMuxChannel(int channel) {
digitalWrite(muxS0, bitRead(channel, 0));
digitalWrite(muxS1, bitRead(channel, 1));
digitalWrite(muxS2, bitRead(channel, 2));
digitalWrite(muxS3, bitRead(channel, 3));
}
void loop() {
for (int ch = 0; ch < numKeys; ch++) {
int muxChannel = numKeys - 1 - ch;
selectMuxChannel(muxChannel);
delayMicroseconds(5);
bool isPressed = digitalRead(muxSIG) == LOW;
if (isPressed && !lastState[ch]) {
usbMIDI.sendNoteOn(baseNote + ch, 127, 1);
} else if (!isPressed && lastState[ch]) {
usbMIDI.sendNoteOff(baseNote + ch, 0, 1);
}
lastState[ch] = isPressed;
}
delay(1);
}
Here are some other pictures



