top of page
Search
  • Writer's pictureMein-bhi-Engineer

KEYPAD

Updated: Aug 6, 2022

A keypad is a set of buttons arranged in a block or "pad" which bear digits, symbols or alphabetical letters. Pads mostly containing numbers are called a numeric keypad. Numeric keypads are found on alphanumeric keyboards and on other devices which require mainly numeric input such as calculators, push-button telephones, vending machines, ATMs, Point of Sale devices, combination locks, and digital door locks.


CIRCUIT DIAGRAM


CODE



#include<Keypad.h>

//const - constant
//variable qualifier, modifies the behaviour of variable, read-only
//byte: stores an 8 bit unsigned number
const byte rows = 4;
const byte cols = 4;

char mapkeys[rows][cols] =
{
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};

byte rowpins[rows] = {9, 8, 7, 6};
byte colpins[cols] = {5, 4, 3, 2};

//keymapping, pin_row, pin_col,nos_rows,nos_cols
Keypad mykeypad = Keypad(makeKeymap(mapkeys), rowpins, colpins, rows, cols);

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  char key=mykeypad.getKey();
  //if some key is pressed, print that key
  //if(key) means some key received
  //if no key is pressed, default key=NO_KEY
  //if(key!=NO_KEY), some key is pressed now
  if(key!=NO_KEY)
  {
    Serial.println(key);
  }
}

13 views0 comments

Recent Posts

See All

Comments


bottom of page