fbpx

Interface Keypad With Arduino Uno

Keypad is essential in all embedded devices where user need to interact with devices.

  • From Calculator to Computer keypad, it’s essential where a number of input switches are required.
  • Keypad is a input device.
  • keypad is made by arranging push button switches in row and columns in a matrix format.
  • In 4×3 matrix keypad 12 input switch are required to connect with microcontroller.
  • The status of input switch can be determine by scanning row and column of keypad.
  • In 4×3 matrix keypad 4 row and 3 columns will available.
  • A logic 0 is given to Row1 and logic 1 is given to Row2&Row4.
  • Column is scanned. If any switch belongs to 1st row is pressed corresponding column will be logic 0 and we can detect the pressed key.
  • This process is repeated for all rows.

Hardware Required

  • 4×3 Keypad.
  • Arduino.

Circuit

Code

 #include <Keypad.h>
 const byte ROWS = 4; //four rows
 const byte COLS = 3; //three columns
 char keys[ROWS][COLS] = {
 {'1','2','3'},
 {'4','5','6'},
 {'7','8','9'},
 {'*','0','#'}
 };
 byte rowPins[ROWS] = {10, 9, 8, 7};
 byte colPins[COLS] = {13, 12, 11};
 Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
 void setup()
 {
 Serial.begin(9600);
 }
 void loop()
 {
 char key = keypad.getKey();
 if (key)
 {
 Serial.println(key);
 }
 }

Leave a Reply

Your email address will not be published. Required fields are marked *