Custom 5x5 Keypad
Hello everyone, and welcome back. Here's something fun and useful. The customized 5x5 button matrix board built from scratch.
Here, we create a simple 25-button matrix board using a simple row-and-column framework, with buttons arranged in five rows and five columns to form a button grid. When you press the button, it completes the circuit between a row and a column, which is detected by the microcontroller and shown on the OLED screen.
The purpose of developing this project was to work on a calculator project that required as many buttons as possible; thus, we created this matrix board to aid us in the tinkering phase of the calculator project.
This article is about the whole build process of this oroject, so let's get started with the built.
Supplies
These were the materials used in this project:
- Custom PCB (provided by Seeed Studio Fusion)
- Tacktile Buttons
- Male header pin connector CON10
- Breadboard
- SSD1306 OLED Screen
- Raspberry Pi PICO 2
- Jumper Wires
Keypad Design Process
We started with our project by arranging all of the buttons in five rows and five columns.
We created a button matrix (inspired by a key matrix board) in which all buttons are placed in a grid of rows and columns, with each row and column connected to a CON10 header pin connector.
The microcontroller scans the matrix by setting each row high and then checking each column. Pressing the button completes the circuit between a row and a column. Knowing which row is high and which column reads the signal allows the microcontroller to determine which button is pressed.
This method decreases the amount of I/O pins required, as we are using 25 buttons, and a standard method would require 25 I/O pins for all buttons; however, this method allows us to utilize only 10 I/O pins overall.
By creating the schematic, we were able to export the netlist and develop the board design for this project, which included placing the buttons in the GRID configuration and linking the traces according to the schematic. We completed the board and then exported the gerber data, which will be shared with a PCB manufacturer to create samples.
Seeed Studio Fusion
Following the completion of the Gerber data, we uploaded the file to Seeed Fusion's website and placed an order for a white Solder mask with black silkscreen.
PCBs were received in a week, and their quality was super good considering the rate, which was also pretty low.
Seeed Fusion PCB Service offers one-stop prototyping for PCB manufacture and PCB assembly, and as a result, they produce superior-quality PCBs and fast turnkey PCBAs within 7 working days.
Seeed Studio Fusion PCB Assembly Service takes care of the entire fabrication process, from Seeed Studio Fusion Agile manufacturing and hardware customization to parts sourcing, assembly, and testing services, so you can be sure that they are getting a quality product.
After gauging market interest and verifying a working prototype, Seeed Propagate Service can help you bring the product to market with professional guidance and a strong network of connections.
PCB Assembly Process
- The assembly process begins with placing all 25 switches in their respective pads on the Matrix PCB; we are utilizing 6x6 Tacktile buttons here, and we must ensure that all buttons are correctly added to their pads, as some of the buttons' pins bend when placed in the footprint.
- Next, we solder all of the switch pads on the bottom side of the board with a soldering iron.
- Following that, we place a CON10 male header pin in its place and solder its pads from the top side of the board.
Matrix Board is now assembled.
Raspberry Pi Pico Setup
- Using a PICO 2, an OLED display, a breadboard, a button matrix, and a few jumper wires, we create a basic setup by connecting all of the column pins from C1 to C5 with GPIO16, GPIO17, GPIO18, GPIO19, and GPIO20.
- GPIO0, GPIO1, GPIO2, GPIO3, and GPIO6 connect rows 1 through 5.
- The OLED screen's VCC is connected to PICO's VBUS, while the GND is connected to GND.
- The SDA of the OLED is linked to PICO's SDA Pin (GPIO4), and the SCL is attached to GPIO5, which is PICO's SCL Pin.
CODE
Here's a quick test drawing we created to see if all of the button mapping is right.
This code initializes an OLED display and sets up a button matrix with swapped rows and columns to detect button presses. When a button is pressed, it identifies which button was pressed, displays the button number on the OLED screen, and updates the display accordingly.
We are using the Adafruit_SSD1306 Library in this sketch, which you need to download and install first before using this code.
Conclusion
Here's the end result of this small butlt, a DIY Keypad matrix that can be used to add multiple buttons to any project by using only a few I/O pins. In this case, we have a total of 25 buttons that would require 25 I/O pins if connected regularly, but this matrix allows the user to only use 10 I/O pins to control 25 buttons, which is ideal if the microcontroller being used has limited I/O pins.
The purpose of developing this matrix was to create a compact calculator with an OLED screen combined to a Raspberry Pi Pico and a button matrix.
Leave a comment if you need any help regarding this project. This is it for today, folks, and stay tuned for the calculator project update.
Special thanks to Seeed Studio Fusion Service for supporting this project. You guys can check them out if you need great PCB and stencil service for less cost and great quality.
And I'll be back with a new project pretty soon, peace.