Introduction: 4×4 Keyboard for Arduino

In Arduino app system, keyboard is one of the indispensable component to man-machine dialogue. When the button is less, we can connect the button to the I/O port of Arduino. While there need more button and the I/O resource of Arduino is limit, it is better to choose the matrix keboard. Next I will demo that use the 4 * 4 keyboard on Arduino.

The original post :

Step 1: Part List

1 x Arduino UNO  
1 x 4*4 keyboard
8 x Wire 

Step 2: Wiring Diagram

Step 3: Test Code

#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;

//define the symbols on the buttons of the keypads
char Keys[ROWS][COLS] =
{
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};

byte rowPins[ROWS] = {2,3,4,5};
byte colPins[COLS] = {6,7,8,9};
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad(makeKeymap(Keys),rowPins,colPins,ROWS,COLS);

void setup()
{
  Serial.begin(9600);
  Serial.println("Please press the keyboard:");
}

void  loop()
{
  char key = customKeypad.getKey();
  if(key!=NO_KEY)
  {
    Serial.print("Key Value : ");
    Serial.println(key);
  }
}

Step 4: Run Test

(1) Connect the wiring according to the wiring diagram

Figure 1

(2)Download the Arduino library in attachment and save it to the Arduino IDE libraries:

Figure 2

(3)     Open the ArduinoIDE and put the test code into the IDE, compile and download:

Figure 3

(4)Open the serial Monitor, set the baud rate to 9600, press any key and you will see the corresponding key value in the monitor;
Figure 4

Step 5: Download

Arduino Library:keypad

Comments

author
HEISENBERG_PN made it! (author)2014-08-10

Great,
perfect for a noobie like me.I not used the same keypad but it's okay

(FR)

10417516_818534804843410_5930201758595965378_n.jpg

About This Instructable

2,423views

11favorites

License:

More by Yanny Guo:Use pcDuino as Photo Booth ControllerUse Si4703 FM Breakout Board on Arduino UnoUse SIM900 GPRS/GSM Shield on pcDuino
Add instructable to: