Ardumotive Arduino Greek Playground
  • Home
    • About us
    • License
  • Arduino
    • Tutorials
    • Workshop
  • Raspberry Pi
  • DIY 3D Printer
  • News
    • Events >
      • Unboxing & Review
    • Blog
The 1st Arduino Playground in Greece - Open Source Hardware

Keypad or Numpad

Available Languages
Greek
English
*Σύντομα και στα Ελληνικά

Introduction 

Picture
A keypad is a set of buttons arranged in a block or "pad" which usually bear digits, symbols and usually a complete set of alphabetical letters. If it mostly contains numbers then it can also be called a numeric keypad. Keypads are found on many alphanumeric keyboards and on other devices such as calculators, push-button telephones, combination locks, and digital door locks, which require mainly numeric input.
In this tutorial you will learn how to use a Numpad (numeric keypad) with Arduino uno.

What you will need - Hardware

For this tutorial you will need:
  • Arduino uno
  • Numpad - Keypad
Picture

The Circuit

Picture
We are using 7 pins keypad with 3 columns and 4 rows.
Note:
If your keypad doesn't work with code on next step you must change the connections above and the pin numbers on those commands. Search the web for additional help or find the datasheet for your keypad.
  • byte rowPins[ROWS] = {7, 2, 3, 5}; //connect to the row pinouts of the keypad
  • byte colPins[COLS] = {6, 8, 4}; //connect to the column pinouts of the keypad

The code

About the code:
The keypad that we are using has 4 rows and 3 columns:
  • 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','*'} };
Tip: If you have another set of keypad you can change those values with yours .
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* How to use a Keypad with Arduino uno
   More info: http://www.ardumotive.com/how-to-use-a-keypad-en.html
   Date: 13/7/2015 // www.ardumotive.com  */

#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','#'}
};

//Change the following pins your yours keypad pinout!
byte rowPins[ROWS] = {7, 2, 3, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6, 8, 4};    //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
  Serial.begin(9600); //Init serial communication
}

void loop(){
  //Read if button is pressed	
  char key = keypad.getKey();
  //Print this button to serial monitor
  if (key != NO_KEY){
    Serial.println(key);
  }
}
Download the code from here and open it with Arduino IDE. Inside you will also find additional libraries.
keypad_tutorial.zip
File Size: 8 kb
File Type: zip
Download File

Open the serial monitor from tools menu of Arduino IDE. Try to press a button.
Picture

Well done!

Picture
You have successfully completed one more Arduino "How to" tutorial and you learned how to use a keypad with Arduino. I hope you liked this, let me know in the comments.

Picture

Search Engine

Picture

Licence 

Picture

Help us to grow up!

Picture


Donate us
About us
License
Cookies policy

Visit the biggest Arduino Shop in Greece!

Picture
find us on dwrean.net
find us on Codebender
find us on Instructables
Developed and designed by Vasilakis Michalis Copyright © 2013 Ardumotive All Rights Reserved
All trademarks referenced herein are properties of their
Powered by Create your own unique website with customizable templates.
Design by DivTag Templates