I’m currently building a MIDI keyboard with an Arduino Mega.
I salvaged an old organ keyboard, removed all electronic components and rebuild the contacts (each octave has an aluminum plate below the keys, which get in contact with it when pressed).
Each key is shorted with every other key (so I have 12 inputs, all C will put the same pin HIGH), and each plate is connected to an output pin, so I can “turn on” just one plate at a time and detect which key in which octave was pressed.
This is a simplified schematic (just 9 buttons in 3 groups), I just did it with 48 keys in groups of 12. Values are accurate.
EDIT : Pin 1, 2, 3 are outputs and only one can be HIGH at any time. Pin 4, 5, 6 are inputs and are used to read the buttons.
I have a 18k pulldown resistor (10k would not work, all pins would always read LOW) and some diodes to prevent interference coming back from the common ground.
My code is on my GitHub (it’s kinda long, sorry for the external link).
When one key is pressed, close pins read HIGH and LOW in what seems a pattern (LEDs associated with them turn on dimly, as if I was PWMing them, and do not just blink as if it was noise). Some keys work and do not affect close pins, others instead when pressed turn HIGH even 5 pins.
I tried reading multiple times and ANDing the results, with no effect : the pins next to the one of the key I pressed still behave badly.
I connected just one octave to 5v output (of the arduino, to have a stable reading) and measured voltage on pins : the one which has its key pressed reads 5v, other pins all read 10mV. I redid the same test with the thing working normally and I read 900mV on the closed buttons (due to the pin turning HIGH and then LOW too quickly for my multimeter) and 1mV on the open ones.
I checked continuity and I don’t have shorts across the plates, across the pins or across the contacts.
I fear I may have some internal damage on my arduino at this point, I really have no more ideas to try. Did I miss something?
Thanks for your time!