Demo Video:
Skema Wiring
List Program:
/* Password for electronics key by: Aan Darmawan date : July 2011 web: http://valfa.blogspot.com */ // include the library code: #include <LiquidCrystal.h> #include <Keypad.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); const byte ROWS = 4; //four rows const byte COLS = 4; //four columns const int nada[8]={ 131,175,262,349,523,698,1047,1397}; char keys[ROWS][COLS] = { { '1','2','3','A' } , { '4','5','6','B' } , { '7','8','9','C' } , { '*','0','#','D' } }; char berita[16]={ ' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' '}; char tampil[16]={ ' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' ', ' ',' ',' ',' '}; byte rowPins[ROWS] = { 14,15,16,17}; //connect to the row pinouts of the keypad byte colPins[COLS] = { 9, 8, 7, 6}; //connect to the column pinouts of the keypad Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); byte k=4,n=0; String jawab,kunci="123456"; void setup() { pinMode(13,OUTPUT); pinMode(10,OUTPUT); digitalWrite(13,LOW); lcd.begin(16, 2); lcd.print("Password:"); } void loop() { //check key pressed char key = keypad.getKey(); if (key != NO_KEY){ berita[n]=key; tampil[n]='*'; tone(10, nada[k],250); n++; if(n>15){ for(n=1;n<=15;n++)berita[n-1]=berita[n]; n=15; berita[n]=' '; } lcd.setCursor(0, 1); lcd.print(tampil); noTone(4); } if(key=='#'){ // jawaban 6 digit pertama yang masuk dipindah ke string for(n=0;n<6;n++)jawab+=berita[n]; if(jawab==kunci){ digitalWrite(13,HIGH); lcd.setCursor(0, 1); lcd.print("Access Granted !"); tone(10, nada[7],1000); } else { lcd.setCursor(0, 1); lcd.print("Access Denied ! "); tone(10, nada[1],500); } delay(1500); for(n=0;n<=15;n++){ berita[n]=' '; tampil[n]=' '; } lcd.setCursor(0, 1); lcd.print(tampil); n=0; jawab=String(); } else digitalWrite(13,LOW); delay(100); }