Stufin
Home Quick Cart Profile

Matrix 16 Button Keypad Module (4x4 Keypad)

Buy Now

Component Name

Matrix 16 Button Keypad Module (4x4 Keypad)

Overview

The Matrix 16 Button Keypad Module, also known as a 4x4 Keypad, is a popular input device used in various applications, including robotics, automation, and IoT projects. This module provides a convenient way to add user input capabilities to a system, allowing users to interact with devices and machines.

Functionality

The Matrix 16 Button Keypad Module is a 4x4 matrix keypad, which means it consists of 16 buttons arranged in a 4-row and 4-column layout. Each button is connected to a microcontroller or a host device through a set of rows and columns, forming a matrix. When a button is pressed, the keypad module sends a signal to the connected device, indicating which button has been pressed.

The keypad module is typically used to send commands, input data, or trigger specific actions in a system. It can be used in a wide range of applications, including

Robotics and automation projects

Home automation systems

Industrial control systems

Medical devices

Vending machines

Alarm systems

Key Features

  • 16 Button Matrix Layout: The keypad module features a 4x4 matrix layout, providing 16 individual buttons that can be pressed to send unique signals to the connected device.
  • Low Power Consumption: The module has a low power consumption, making it suitable for battery-powered devices and reducing energy costs.
  • High-Quality Buttons: The buttons are designed to be durable and provide a tactile feedback when pressed, ensuring reliable operation even in harsh environments.
  • Easy Integration: The keypad module can be easily integrated with microcontrollers, Arduino boards, Raspberry Pi, and other devices using standard communication protocols such as UART, SPI, or I2C.
  • Compact Size: The module is compact and lightweight, making it suitable for use in space-constrained applications.
  • Operating Voltage: The keypad module typically operates on a voltage range of 3.3V to 5V, making it compatible with most microcontrollers and devices.
  • Simple Wiring: The module requires only a few wires to connect to the host device, simplifying the wiring process and reducing the risk of errors.

Technical Specifications

Dimensions

46 x 46 mm (1.8 x 1.8 in)

Button Size

12 x 12 mm (0.47 x 0.47 in)

Operating Voltage

3.3V to 5V

Current Consumption

<10mA (average)

Communication Protocol

UART, SPI, or I2C (dependent on the microcontroller or host device)

Operating Temperature

-20C to 70C (-4F to 158F)

Applications

Robotics and automation projects

Home automation systems

Industrial control systems

Medical devices

Vending machines

Alarm systems

Conclusion

The Matrix 16 Button Keypad Module is a versatile and reliable input device that provides a convenient way to add user input capabilities to a wide range of applications. Its compact size, low power consumption, and easy integration make it an ideal choice for designers and engineers working on IoT and automation projects.

Pin Configuration

  • Matrix 16 Button Keypad Module (4x4 Keypad) Pinout Explanation
  • The Matrix 16 Button Keypad Module (4x4 Keypad) is a versatile input device for various IoT projects. It features a 4x4 matrix keyboard layout, consisting of 16 buttons, and is commonly used in robotics, automation, and other interactive applications. Here's a detailed explanation of the module's pins and their connections:
  • Pinout Structure:
  • The module has a total of 8 pins, arranged in two rows of 4 pins each. The pins are labeled as follows:
  • Row 1:
  • 1. VCC (Pin 1): This is the power supply pin, which should be connected to a positive voltage source (typically +5V).
  • 2. R1 (Pin 2): Row 1 output pin, connected to the microcontroller or other logic circuitry.
  • 3. R2 (Pin 3): Row 2 output pin, connected to the microcontroller or other logic circuitry.
  • 4. R3 (Pin 4): Row 3 output pin, connected to the microcontroller or other logic circuitry.
  • Row 2:
  • 1. GND (Pin 5): This is the ground pin, which should be connected to a negative voltage source (typically 0V).
  • 2. C1 (Pin 6): Column 1 input pin, connected to the microcontroller or other logic circuitry.
  • 3. C2 (Pin 7): Column 2 input pin, connected to the microcontroller or other logic circuitry.
  • 4. C3 (Pin 8): Column 3 input pin, connected to the microcontroller or other logic circuitry.
  • Connection Diagram:
  • To connect the Matrix 16 Button Keypad Module to a microcontroller or other logic circuitry, follow these steps:
  • 1. Connect VCC (Pin 1) to the positive voltage source (+5V).
  • 2. Connect GND (Pin 5) to the negative voltage source (0V).
  • 3. Connect R1 (Pin 2), R2 (Pin 3), and R3 (Pin 4) to digital input pins on the microcontroller or other logic circuitry.
  • 4. Connect C1 (Pin 6), C2 (Pin 7), and C3 (Pin 8) to digital output pins on the microcontroller or other logic circuitry.
  • Scanning the Keypad:
  • To read the keypad inputs, the microcontroller or other logic circuitry needs to scan the rows and columns using a multiplexing technique. Here's a general outline of the scanning process:
  • 1. Set R1 (Pin 2), R2 (Pin 3), and R3 (Pin 4) as output pins and set them to LOW (0V) initially.
  • 2. Set C1 (Pin 6), C2 (Pin 7), and C3 (Pin 8) as input pins with internal pull-up resistors enabled.
  • 3. Scan the rows by setting one row pin (R1, R2, or R3) to HIGH (5V) and read the corresponding column pins (C1, C2, or C3).
  • 4. Repeat step 3 for each row, reading the column pins after each row selection.
  • 5. Determine the pressed key by analyzing the column pin states for each row selection.
  • By following these connection and scanning instructions, you can effectively use the Matrix 16 Button Keypad Module in your IoT projects.

Code Examples

Matrix 16 Button Keypad Module (4x4 Keypad) Documentation
Overview
The Matrix 16 Button Keypad Module is a 4x4 keypad module that allows users to interface with a microcontroller or other digital systems. This module is ideal for various applications, such as home automation, robotics, and industrial control systems, where a compact and efficient keypad interface is required.
Technical Specifications
Keypad size: 4x4 (16 buttons)
 Interface: Digital output ( Rows: 4, Columns: 4)
 Operating voltage: 5V
 Communication protocol: None (direct digital output)
 Dimensions: 60mm x 40mm x 10mm (approx.)
Pinout
The module has a total of 8 pins, divided into two rows of 4 pins each:
Rows: R1, R2, R3, R4
 Columns: C1, C2, C3, C4
Code Examples
### Example 1: Basic Keypad Reading (Arduino)
In this example, we will connect the keypad module to an Arduino board and read the keypad inputs.
Connections:
R1 - R4 to digital pins 2-5 on the Arduino board
 C1 - C4 to digital pins 6-9 on the Arduino board
Code:
```c++
const int rowPins[] = {2, 3, 4, 5};
const int colPins[] = {6, 7, 8, 9};
void setup() {
  Serial.begin(9600);
  
  // Initialize row pins as outputs
  for (int i = 0; i < 4; i++) {
    pinMode(rowPins[i], OUTPUT);
  }
  
  // Initialize column pins as inputs
  for (int i = 0; i < 4; i++) {
    pinMode(colPins[i], INPUT);
  }
}
void loop() {
  for (int i = 0; i < 4; i++) {
    digitalWrite(rowPins[i], HIGH);
    for (int j = 0; j < 4; j++) {
      if (digitalRead(colPins[j]) == LOW) {
        Serial.print("Button ");
        Serial.print(i  4 + j + 1);
        Serial.println(" pressed!");
        delay(50); // Debouncing
      }
    }
    digitalWrite(rowPins[i], LOW);
  }
}
```
### Example 2: Keypad Input Debouncing (Raspberry Pi with Python)
In this example, we will connect the keypad module to a Raspberry Pi and implement debouncing to eliminate multiple key presses.
Connections:
R1 - R4 to GPIO pins 17-20 on the Raspberry Pi
 C1 - C4 to GPIO pins 21-24 on the Raspberry Pi
Code:
```python
import RPi.GPIO as GPIO
import time
# Set up GPIO pins
GPIO.setmode(GPIO.BCM)
row_pins = [17, 18, 19, 20]
col_pins = [21, 22, 23, 24]
for pin in row_pins + col_pins:
    GPIO.setup(pin, GPIO.OUT if pin in row_pins else GPIO.IN, pull_up_down=GPIO.PUD_UP)
def read_keypad():
    for i in range(4):
        GPIO.output(row_pins[i], GPIO.HIGH)
        for j in range(4):
            if GPIO.input(col_pins[j]) == GPIO.LOW:
                # Debounce mechanism: wait 50ms and check again
                time.sleep(0.05)
                if GPIO.input(col_pins[j]) == GPIO.LOW:
                    return i  4 + j + 1
        GPIO.output(row_pins[i], GPIO.LOW)
    return None
while True:
    key = read_keypad()
    if key is not None:
        print(f"Button {key} pressed!")
    time.sleep(0.1)
```
### Example 3: Keypad-based Menu System (ESP32 with MicroPython)
In this example, we will connect the keypad module to an ESP32 board and implement a simple menu system using MicroPython.
Connections:
R1 - R4 to GPIO pins 18-21 on the ESP32 board
 C1 - C4 to GPIO pins 22-25 on the ESP32 board
Code:
```python
import machine
import utime
# Set up GPIO pins
row_pins = [machine.Pin(18, machine.Pin.OUT), machine.Pin(19, machine.Pin.OUT), machine.Pin(20, machine.Pin.OUT), machine.Pin(21, machine.Pin.OUT)]
col_pins = [machine.Pin(22, machine.Pin.IN), machine.Pin(23, machine.Pin.IN), machine.Pin(24, machine.Pin.IN), machine.Pin(25, machine.Pin.IN)]
menu_items = ["Item 1", "Item 2", "Item 3", "Item 4"]
def read_keypad():
    for i in range(4):
        row_pins[i].value(1)
        for j in range(4):
            if col_pins[j].value() == 0:
                return i  4 + j
        row_pins[i].value(0)
    return None
def display_menu(menu_item):
    print(f"Menu item: {menu_items[menu_item-1]}")
while True:
    key = read_keypad()
    if key is not None:
        display_menu(key+1)
    utime.sleep(0.1)
```
These examples demonstrate how to read the keypad inputs using different microcontrollers and programming languages. You can adapt and modify the code to suit your specific application requirements.