“A simple PCB keyboard that you can easily use for your Arduino project. Fully-customizable code provided!
I am currently working on a project that will have an integrated keyboard, which presented a problem: how do I include a keyboard in the development board prototype? I can’t use a USB keyboard or an existing Arduino-based keyboard, because the keyboard in the actual project is connected directly to the microcontroller that handles all of the other functions. So I designed this basic PCB-based 64-key prototyping keyboard matrix.
This PCB does not contain any ICs (integrated circuits). The rows and columns of the keyboard matrix are connected directly to the pin headers so that the keyboard can be connected to an Arduino or any other microcontroller. It is perfect for prototyping your projects that will include an integrated keyboard.
I have included detailed, heavily-commented code to make this work with any Arduino-compatible development board that has an enough I/O pins available—11 pins are required. The keyboard has 64 keys, including modifiers for shift, caps, ctrl, alt, fn, and “special.” There are also six additional keys that can be used for whatever you like. Every single key’s functions can be defined individually, including each key’s function when a modifier is active. In my opinion, this is significantly more useful than existing keyboard code that severely limits your ability to customize key behavior.
The code provided will print text to Serial. This can easily be changed if you want the text to go somewhere else.
A Note Regarding Program Size:
The code that I provide is pretty large, because it doesn’t utilize any existing libraries whatsoever. I wrote this code completely from scratch in order to enable the customizability that I required. On an Arduino UNO, this will use 9100 bytes (28%) of program storage space and global variables use 394 bytes (19%) of dynamic memory.
My code could probably be more efficient and there libraries and sketches for keyboards are certainly smaller, but this is the only way I could devise to provide complete flexibility over every key with every modifier. It also takes into account real-world keyboard usage. For example, with my code pressing the Shift key while Caps Lock is enabled will result in a lowercase letter as it should. By default, holding down the FN key while pressing ESC won’t do anything. But that behavior is completely customizable, so you can change it however you like.”