#include <Keypad.h>
#define buzz 10
#define LED 12
const int ROW_NUM = 4; // four rows
const int COLUMN_NUM = 4; // four columns
char keys[ROW_NUM][COLUMN_NUM] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte pin_rows[ROW_NUM] = {9, 8, 7, 6}; // connect to the row pinouts of the keypad
byte pin_column[COLUMN_NUM] = {5, 4, 3, 2}; // connect to the column pinouts of the keypad
Keypad keypad = Keypad(makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );
void setup() {
Serial.begin(9600);
pinMode(buzz, OUTPUT);
pinMode(LED, OUTPUT);
}
void loop() {
char key = keypad.getKey();
if (key) {digitalWrite(LED, HIGH);delay(50);}else{digitalWrite(LED, LOW);}
if (key=='1') {tone(buzz,900);delay(100);noTone(buzz);}
if (key=='2') {tone(buzz,225);delay(100);noTone(buzz);}
if (key=='3') {tone(buzz,350);delay(100);noTone(buzz);}
if (key=='4') {tone(buzz,455);delay(100);noTone(buzz);}
if (key=='5') {tone(buzz,500);delay(100);noTone(buzz);}
if (key=='6') {tone(buzz,552);delay(100);noTone(buzz);}
if (key=='7') {tone(buzz,850);delay(100);noTone(buzz);}
if (key=='8') {tone(buzz,875);delay(100);noTone(buzz);}
if (key=='9') {tone(buzz,550);delay(100);noTone(buzz);}
if (key=='A') {tone(buzz,725);delay(100);noTone(buzz);}
if (key=='B') {tone(buzz,900);delay(100);noTone(buzz);}
if (key=='C') {tone(buzz,600);delay(30);noTone(buzz);}
if (key=='D') {tone(buzz,750);delay(450);noTone(buzz);}
if (key=='0') {tone(buzz,800);delay(400);noTone(buzz);}
if (key=='*') {tone(buzz,100);delay(100);noTone(buzz);}
if (key=='#') {tone(buzz,100);delay(100);noTone(buzz);}
}