Table of Contents

Interfacing 4×4 Keypad Module with Arduino (Part 1)

Example Description
Learn about the 4x4 keypad module's working principle and applications. Explore how to interface a 4x4 keypad module with Arduino using Pictoblox.
Introduction

A 4×4 keypad module is an electronic input device commonly used in various applications for interfacing with microcontrollers and other digital systems. It consists of a grid of buttons arranged in a 4×4 matrix, resulting in a total of 16 buttons. Each button corresponds to a specific alphanumeric character, symbol, or command.

Working Principle: A technique called “keypad scanning” is used to read input from the keypad. The microcontroller scans the rows and columns one by one. It sets one row to HIGH and reads the column pins to detect if any button in that row is pressed. If a button is pressed, the corresponding row and column will intersect, allowing the microcontroller to determine the button that was pressed.

Applications: 4×4 keypad modules are widely used in various applications that require user input, such as security systems, door locks, industrial control panels, calculators, home automation, and more.

In this example, we will be interfacing the keypad module with Arduino and try to read the button value from the keypad module. let’s begin!!

Circuit diagram

Code

  1. Open pictoblox and create a new file.
  2. from boards, select Arduino Uno.
  3.  change Scripting mode from stage to upload.
  4. from extension button add “communication” extension and “Advance sensor” extension.
  5. create a variable “key value” of type string.
  6. From Arduino palette, add “When Arduino Starts up” block into the scripting area.
  7. From advanced sensors, Drag initilize keypad module block and add with above block.
  8. Now we need to start the Serial communication for Arduino. From the communication palette add Now from variable palette, add “set () to ()” block with above block “Set Serial()  baud rate to ()” in the script and set baud rate to 9600.
  9. Now from variables, we block “set () to ()” select the key value from the list and remove the  0 (make a empty string variable).
  10.  Add a forever loop from controls palette.
  11. Now from advanced sensors store the value of key pressed in key value variable.
  12.  Add a if block from controls palette into the scripting area and add greater than operator from operator palette.
  13.  Now if the length of key value operator is greater than 0, that means the user has pressed a key.  Use lenght of ( ) block from operators
  14.  Inside this if block we will be print the key value on Serial monitor using the communication palette. use the block “write () on Serial ()” from communication palette and place the key value variable in the space provided.
  15. Now delete all the data of key value variable using “set () to ()” block from variables.
  16. add this if block in forever block.

in this way we can connect our keypad module with Arduino.

 

Output:

OUTPUT GIF will be updated soon.