In this tutorial, you will build a breadboard keyboard with 4 keys. The keyboad will be used in tutorials 2 through 7.
When you finish this tutorial you will have a working keyboard and an understanding of how a key matrix works.
Breadboard keyboards have key matrices and diodes just like the big keyboards.
A breadboard is the easiest way to learn keyboard electronics. Learning is fun when mistakes are easily corrected. Compared to PCBs, breadboard keyboards make learning faster because:
Breadboard keyboards are useful for:
The parts needed to build the tutorial breadboard keyboards are listed in breadboard_keyboard_supplies.ods.
The tutorials use a Teensy LC controller, but any Arduino-compatible controller with at least 2 KB SRAM should work.
You will need two tools:
Wire striper, lead-forming tool, and Anti-static mat are optional.
To understand the breadboard keyboard you will need to know the internal parts of a breadboard:
These are explained in How to Use a Breadboard
Static electricity can damage a ICs in ways that are hard to trouble shoot.
Here is a ESD precaution for handling ICs:
I take these ESD precaution because I live in a dry environment on a carpeted floor. Not everyone needs to take ESD precautions:
Anti-static mat or anti-static wristband are also effective. But being tethered by an anti-static wristband can be inconvenient (wireless antistatic wrist straps are a scam).
The basic breadboard keyboard has 4 switches.
A Teensy LC microcontroller is on the left. A key matrix with 4 switches is to the right.
The key matrix has two two columns. Short wires connect terminal strips into matrix columns. Jumper wires connect the columns to the microcontroller.
Two bus strips are used as matrix rows. A jumper connects the top row to the microcontroller. A short wire connects the bottom row to the microcontroller.
A switches and diodes connect rows to columns.
Tutorials 2 and 3 use the same basic breadboard keyboard pictured above. Tutorials 4, 5, and 6 add more components to the basic breadboard keyboard. Positioning components as shown in the picture will provide space for those components.
Breadboard keyboard assembly instructions:
Pin number | Connects to |
---|---|
0 | row_0 |
1 | row_1 |
14 | col_0 |
15 | col_1 |
Follow the keybrd Library User’s Guide to set up the Arduino environment.
Compile and load the keybrd_1_breadboard.ino sketch into the keyboard’s controller. The operating system will take 1 to 6 seconds to recognize the USB keyboard. Then pressing the keys should type the characters 1, 2, a, b. Congratulations, you have a working keyboard.
Now we fill in some details of how it all works.
This excellent article explains how key matrix, diodes, and ghosting work: How a Key Matrix Work
In the article:
Output pins power columns and input pins detect the power on rows.
The breadboard keyboards in this series of tutorials do it the other way:
Output pins power rows and input pins detect the power on columns.
The keybrd library uses the word “strobe”, which means powering one row for a very short time. Strobe pins are output pins connected to rows. One row at a time is strobed. While a row is strobed, input pins connected to the columns sense which buttons are pressed.
1) replace the diodes with wires (cutoffs) and intentionally cause ghosting.
keybrd tutorial by Wolfram Volpi is licensed under a Creative Commons Attribution 4.0 International License.
Permissions beyond the scope of this license may be available at https://github.com/wolfv6/keybrd/issues/new.