#include <Keypad.h>
#include <LiquidCrystal.h>
#include <Wire.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);

/* Keypad setup */
const byte KEYPAD_ROWS = 4;
const byte KEYPAD_COLS = 4;
byte rowPins[KEYPAD_ROWS] = {5, 4, 3, 2};
byte colPins[KEYPAD_COLS] = {A3, A2, A1, A0};
char keys[KEYPAD_ROWS][KEYPAD_COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '3', 'D'}
};

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, KEYPAD_ROWS, KEYPAD_COLS);


void setup()
 {
 pinMode(6, OUTPUT);
 lcd.begin(20,4);
 lcd.print("632021117 chanawee");
}

void loop()
 {
  char key = keypad.getKey();
  if(key=='1'){digitalWrite(6, HIGH);tone(13,1500);delay(100);noTone(13);}
  if(key=='7'){digitalWrite(6, LOW);tone(13,2000);delay(100);noTone(13);}

  if(key=='A'){ 
    digitalWrite(6, HIGH);
    for(int i=7;i>=0;i--){
        if(i==0){
          digitalWrite(6, LOW);
          tone(13,1500);delay(3000);
        }
   lcd.setCursor(8,3);
    lcd.print(i);
   delay(1300);
  

    } 
  }
}