Experiment No-5
AIM: Interfacing of keypad with Arduino embedded target board as 3×3 matrix and display the pressed
key on serial monitor.
APPARATURS:
1. Arduino embedded target board
2. Keypad
CIRCUIT DIAGRAM:
PROGRAM:
#include <Keypad.h>
const byte ROWS = 3; //three rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] =
{
{'1','2','3'},
{'4','5','6'},
{'7','8','9'}
};
byte rowPins[ROWS] = {11, 10, 9};
//connect to the row pins of keypad
byte colPins[COLS] = {7, 6, 5};
//connect to the column pins of keypad
Keypad keypad = Keypad(
makeKeymap(keys), rowPins, colPins, ROWS,
COLS );
void setup()
{
[Link](9600);
}
void loop()
{
char key = [Link]();
if (key == '1')
{
[Link]("Key Pressed= 1");
}
if (key == '2')
{
[Link]("Key Pressed= 2");
}
if (key == '3')
{
[Link]("Key Pressed= 3");
}
if (key == '4')
{
[Link]("Key Pressed= 4");
}
if (key == '5')
{
[Link]("Key Pressed= 5");
}
if (key == '6')
{
[Link]("Key Pressed= 6");
}
if (key == '7')
{
[Link]("Key Pressed= 7");
}
if (key == '8')
{
[Link]("Key Pressed= 8");
}
if (key == '9')
{
[Link]("Key Pressed= 9");
}
}
Conclusion: