0% found this document useful (0 votes)
9 views3 pages

Arduino 4x4 Keypad Setup Guide

This document provides an Arduino code example for interfacing a 4x4 keypad using the Keypad library. It details the keypad layout, pin connections, and functionality, including real-time key monitoring and non-blocking detection. The setup allows for key presses to be sent to the Serial Monitor at a baud rate of 9600.

Uploaded by

suhelahmed0990
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Arduino 4x4 Keypad Setup Guide

This document provides an Arduino code example for interfacing a 4x4 keypad using the Keypad library. It details the keypad layout, pin connections, and functionality, including real-time key monitoring and non-blocking detection. The setup allows for key presses to be sent to the Serial Monitor at a baud rate of 9600.

Uploaded by

suhelahmed0990
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Arduino 4x4 Keypad Interface

Arduino Code

#include<Keypad.h>

const byte Rows = 4;


const byte Cols = 4;

char keys[Rows][Cols] = {
{'1','2','3','+'},
{'4','5','6','-'},
{'7','8','9','*'},
{'@','0','#','%'}
};

byte rowpins[Rows] = {9, 8, 7, 6};


byte colpins[Cols] = {5, 4, 3, 2};

Keypad keypad = Keypad(makeKeymap(keys), rowpins, colpins, Rows, Cols);

void setup() {
[Link](9600);
}

void loop() {
char key = [Link]();
if(key) {
[Link]("key pressed: ");
[Link](key);
}
}

Code Summary

Library Required

Keypad.h - Install from Arduino Library Manager

generated by "Markdown to PDF Fast Converter" 👉 [Link]


Configuration
Keypad Layout (4x4):

| 1 | 2 | 3 | + |
| 4 | 5 | 6 | - |
| 7 | 8 | 9 | * |
| @ | 0 | # | % |

Pin Connections

Keypad Pin Arduino Pin Type

Row 1 9 Output

Row 2 8 Output

Row 3 7 Output

Row 4 6 Output

Col 1 5 Input

Col 2 4 Input

Col 3 3 Input

Col 4 2 Input

Functionality

Operation:

1. Continuously scans the 4x4 keypad matrix


2. Detects any key press
3. Sends pressed key to Serial Monitor at 9600 baud rate
4. Displays output in format: "key pressed: X"

Features:

Non-blocking key detection


Real-time key monitoring
Supports all 16 keys including special characters

Hardware Setup

generated by "Markdown to PDF Fast Converter" 👉 [Link]


Keypad Module:

Standard 4x4 matrix keypad


8 pins total (4 rows + 4 columns)

Wiring:

Connect row pins to Arduino digital pins 9, 8, 7, 6


Connect column pins to Arduino digital pins 5, 4, 3, 2
No external pull-up resistors needed (handled by library)

Usage Example

Serial Monitor Output:

key pressed: 1
key pressed: 5
key pressed: +
key pressed: #

generated by "Markdown to PDF Fast Converter" 👉 [Link]

You might also like