Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[General] Keypad Interfacing with Arduino

Status
Not open for further replies.

K Srinivas Pavan Kumar

Member level 3
Joined
Jun 20, 2015
Messages
66
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
524
Hi friends,
I have been using the 4x4 keypad interfacing with arduino I have written code .
It is working fine
When I am pressing the 2 it is printing 4 i.e interchanging of rows and columns.
I will give u the code can anybody solve this problem
I have a project on this.

#include <Keypad.h>

const byte ROWS = 4; // Four rows
const byte COLS = 4; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'#','0','*','D'}
};

// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 5, 4, 3, 2 };
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 9, 8, 7, 6 };

// Create the Keypad
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);
}
}
 

Change

Code:
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'#','0','*','D'}
};

to

Code:
char keys[ROWS][COLS] = {
{'1','4','7','#'},
{'2','5','8','0'},
{'3','6','9','*'},
{'A','B','C','D'}
};
 
Thanks Dude,
One More question
I want to make use of this Keypad Without Keypad library, Can u help me in this also
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top