You are on page 1of 5

#include <MultitapKeypad.

h>

#include <Servo.h>

#include <LiquidCrystal.h>

Servo myservo;

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

long dtKey=0;

const byte ROWS = 4; //four rows

const byte COLS = 3; //three columns

char keys[ROWS][COLS] = {

{'1','2','3'},

{'4','5','6'},

{'7','8','9'},

{'*','0','#'}
};

byte rowPins[ROWS] = {7, 6, 5, 4}; //connect to the row pinouts of the

keypad

byte colPins[COLS] = {3, 2, 1}; //connect to the column pinouts of the

keypad

Keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup() {

myservo.attach(6);

Serial.begin(9600);

lcd.begin(16,2);

keypad.addEventListener(keypadEvent);

void loop() {

keypad.getKey();

myservo.write(0);
}

void keypadEvent(KeypadEvent eKey){

switch (keypad.getState()){

case PRESSED:

Serial.print("Enter: ");

Serial.println(eKey);

delay(10);

Serial.write(254);

switch (eKey){

case 'A': Login(); delay(1); break;

case 'B': password.reset(); delay(1); break;


default: password.append(eKey); delay(1);

void Login(){

if (password.evaluate()){

lcd.println("Akses Diterima!");

Serial.write(254);

myservo.write(90);

else{

lcd.println("Akses Ditolak!");

Serial.write(254);

delay(10);

myservo.write(0);

}
}

You might also like