Arduino Digital Piano

Hello , this is my first post in this forum. I want to build an arduino keyboard with 61keys and I've made the keys and case etc. , so i want to play like a normal digital piano with midi output to my pc.

My problem is , i don't know how to take informations from 61keys with using some components like shift registers. Can i use shift registers to reduce the pin number?

And can i connect all of them and play chords (lots of keys with same time) ?

thanks for your help

Normally you could connect keys in a matrix, like say 9X7 would provide 63 keys, or 8X8 would provide 64 both with 16 pins.

That would however take most of the pins on an Uno. You could use a Mega.

I assume you want to detect multiple keys pressed at the same time. There are probably dedicated ICs available to handle the decoding. But if you want to do it with ordinary components, then I suggest you organize your 61 keys as an 8x8 matrix (with 3 spare positions) and connect a 1N4148 or similar diode in series with each key. Drive the columns either from 8 Arduino outputs, or from the outputs of a 74HC138 which in turn is driven from 3 Arduino outputs. Connect the rows to 8 Arduino inputs, each set to mode INPUT_PULLUP; so that when you press a key, the cathode of a diode is connected to one of the column outputs, and the anode is connected to one of the row inputs. Then all you need to do in the software is to set each of the column outputs low in turn, and see which rows have been pulled low because the corresponding keys are depressed.

I would suggest matrix is a poor choice for this. Use a bank of 8 shift registers, and read in the state of all keys at one time and then process the keys that are pressed.
Can use a diode from each key such that a key press pulls the cathode for its diode low, with all anodes connected together, thus Any key press will cause a low common-anode which can be used to signal an interrupt and tell the processor to shift in 8 bytes via SPI.transfer, and in about 12 microseconds all keys can be read in and processed.

Can i use 74HC595 ? And i think i should connect them in series? And do i need to write the code with SPI library one register by one? thanks for your answers

HC595 is an output device.
You need a parallel load, serial output device, such as 74CH165

Code to read them all in is easy:

digitalWrite (loadPin, LOW);
digitalWrite (loadPin, HIGH);
dataIn[0] = SPI.transfer(dummyByte); // dummyByte goes out on MOSI while data is read on MISO
dataIn[1] = SPI.transfer(dummyByte);
dataIn[2] = SPI.transfer(dummyByte);
dataIn[3] = SPI.transfer(dummyByte);
dataIn[4] = SPI.transfer(dummyByte);
dataIn[5] = SPI.transfer(dummyByte);
dataIn[6] = SPI.transfer(dummyByte);
dataIn[7] = SPI.transfer(dummyByte);

Yes, daisy chain them.
Be sure to have 0.1uF cap to Gnd on Each shift register's power pin.

Thanks a lot sir. I have one more question , after defining button numbers to a midi notes with arduino , can arduino send midi data to pc(via usb) and the sorftware (like fl.studio) can get this like any other midi input?

bahadirG:
Thanks a lot sir. I have one more question , after defining button numbers to a midi notes with arduino , can arduino send midi data to pc(via usb) and the sorftware (like fl.studio) can get this like any other midi input?

I have not seen any project that will send USB MIDI directly from an Arduino. That might be feasible on an Arduino Leonardo which can emulate USB devices. The easiest way might be to send MIDI (the original serial kind) using the MIDI library and buy a cheap MIDI to USB converter to get it into a PC. They can be had on eBay for $6.

I wrote the code in this link and correct the pins or etc. , but i just observe all HIGH or all LOW.(link is : http://playground.arduino.cc/Code/ShiftRegSN74HC165N )

At least i know that my problem is in the coding part :smiley: but i couldn't really basic explanation for a starter