Interfacing Keypad with Arduino
Library Required: Keypad (By Mark Stanley)
#include <Keypad.h>
const int r = 4; // No. of rows
const int c = 4; // no. of columns
char keys[r][c] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[r] = {9, 8, 7, 6}; // pins to connect with Arduino
byte colPins[c] = {5, 4, 3, 2}; // pins to connect with Arduino
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, r, c );
void setup()
{
Serial.begin();
}
void loop(){
char key = keypad.getKey();// Reading the key
Serial.print(" You pressed :");
Serial.println(key);
delay(10);
}
Arduino Development Platform
No comments:
Post a Comment