Can someone help me with any suggestions? I want to create a matrix of push buttons with assigned pre-recorded data to each of the keys (e.g. 128x128). So, when any key is pressed this has to send a pre-recorded information (some kind of string) to a RS232 line which then will be received by a PC and manipulated by a program of mine which should decide which key is activated by the given info (string) It sounds complicated, particularly that my English is not that good!
Basically, I want to implement the matrix with the hardware and software relevant to it. I would need any help.
Do you mean a matrix 128x128 keys large? My eyes hurt just thinking about soldering 16384 switches. You won't be able to send pre-recorded messages. You only have 16384 bytes of storage total on the largest Arduino.
In general, a matrix of keys is handled by making a grid of row and column wires, and at each intersection putting a switch between the wires. Then you set all the rows to be inputs with pull-up resistors and set all the rows as outputs, set high. Finally, one by one you set one row to 0 and look to see if any of the columns went to zero. If it did you know which (row,column) pair has its key pressed.
You will notice in the article that you need one IO port for each row and column. You are about 240 pins short on an Arduino, so you will need some sort of IO expander. Perhaps you could use 74HC166 shift registers for the inputs and 74HC165 shift registers for the outputs. You can attach all the output shift registers together in a line so they feed each other and drive them with just a few signals. Likewise all the input registers can be tied together. That would get you the 128 outputs and 128 inputs, you'll need to add the pull up resistors externally I think.
Scan rate will be an issue. If you write clever code (access ports directly) it will take you maybe 1 microsecond to check each key. If you use the digitalRead() and digitalWrite() functions it will take about 15 microseconds and you will only scan the key field four times per second.
Has anyone figured out a working code for this situation? I'm a beginner but have managed to create an 32 pushbutton video controller. I used 4 4021B shift registers and have been working and learning off the shift register tutorial, but I am mixed up by my mulitple daisy chaining and the example's use of toggle switches. I'm a learn by trying type, but any language guidance would be much appreciated.
Thanks,
scrap
Standard scanning keypad techniques can be used with the Arduino. Using 16 digital lines one can make a 64 key keypad (16 lines / 2 = 8, 8*8 = 64). The only things needed are 64 SPST momentary on switches, 8 pull up resistors, software for scanning, and debounce (in software).
One could use the leftover digital line and use SPDT switches (for half of the switches, anyway) and double the total key count to 128.