Arduino Piano Keyboard

Hi, I'm wanting to make an Arduino keyboard out of some 3D-Printed parts. I'm making a 41 key keyboard and am wondering if anyone has made anything like that that can tell me how I go about coding the program for it. Any help would be useful. I'm also looking at putting an aux jack and/or a 1/4 inch port in it. Thanks!

A Mega could read 41 inputs.
Aux port? What do You think of then?
Quarter inch port? What is that?

Coding to read 41 button presses is easy. Wire up each one to connect a pin to Gnd. Some simple code to get you started with an array of pin numbers.

byte inputPins[] = {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,};
byte x;

void setup(){
  for (x = 0; x <42; x=x+1){
  pinMode (x, INPUT_PULLUP);
  Serial.begin(115200); // make sure Serial Monitor speed matches
void loop(){
  for (x =0; x<42; x=x+1){
    if (digitalRead(x) == 0){ // key pressed

Clearly a proper description needed here. :astonished:

41 separate normally-open switches can be wired in a matrix with a diode in series with each, requiring only 13 pins to read an thus, not a Mega 2560.

However, if you are using the "traditional" silver wire contacts with a common NC and NO rail and a 47k resistor on each contact to a common "test" output, you can use a Mega to perform velocity sensing.

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