memanggil library #include #include #include #include #define SS_PIN 10 #define RST_PIN 9 RFID rfid(SS_PIN, RST_PIN); LiquidCrystal lcd(14, 15, 16, 17, 18, 19); // LCD //kode IDtag rfid : int serNum[5]; int cards[][5] = { {38,218,247,72,67}, // card 1 {225,247,166,229,85} // card 2 }; // inisialisasi kolom dan baris keypad const byte ROWS = 4; const byte COLS = 3; char keys[ROWS][COLS] = { {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'} }; byte rowPins[ROWS] = {7,6,5,4}; byte colPins[COLS] = {3,2,1}; Keypad customKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS); // variabel int relay = 8; int index = 0;
Titles you can't find anywhere else
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Titles you can't find anywhere else
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
String code; String pass; String pass1; String pass2; bool testCard, testCode; // setup void setup() { lcd.begin(16, 2); SPI.begin(); rfid.init(); pinMode(relay, OUTPUT); digitalWrite(relay, HIGH); code = String("0000"); pass = String("1235"); pass1 = String("1122"); pass2 = String("2233"); lcd.clear(); lcd.setCursor(0,0); lcd.write("STMIK AKBA"); lcd.setCursor(0,1); lcd.write("MAKASSAR"); delay(5000); lcd.clear(); lcd.write("SCAN ID"); testCard = false; testCode = false; }
Titles you can't find anywhere else
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
// Uji kartu benar dan password benar if (testCode && testCard){ // menampilkan ke lcd
lcd.clear(); lcd.setCursor(0, 0); lcd.print("PASSWORD : ");
lcd.print(code); lcd.setCursor(0, 1);
lcd.print("CORRECT"); digitalWrite(relay ,LOW); delay(2000); // delay 2 menit
//Menutup Kunci testCard = false; testCode = false;
lcd.clear(); digitalWrite(relay, HIGH); }
// uji kartu baik dan password salah if(testCard && !testCode){ lcd.setCursor(0, 0); lcd.print("PASSWORD ?"); if (keypressed != NO_KEY) { lcd.setCursor(index, 1);
lcd.print(keypressed); code[index] = keypressed; index++;
Titles you can't find anywhere else
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
if (code == pass || code == pass1 || code==pass2){ // code OK testCode = true; }else { // code PAS OK lcd.setCursor(0, 0); lcd.print("PASSWORD : ");
lcd.print(code); lcd.setCursor(0, 1);
lcd.print("INCORRECT");
delay(4000); testCode = false; testCard = false; }
lcd.clear(); } }
// tes kartu salah if (!testCard) { lcd.setCursor(0,0); lcd.print("SCAN ID"); if (rfid.isCard()) { if (rfid.readCardSerial()) { for(int x = 0; x < sizeof(cards); x++){ for(int i = 0; i < sizeof(rfid.serNum); i++ ){ if(rfid.serNum[i] != cards[x][i]){ testCard = false;
Titles you can't find anywhere else
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
} }
if(testCard)break; } }
if(!testCard){
lcd.clear(); lcd.write("ID INCORRECT"); delay (2000); lcd.clear (); lcd.write ("SCAN ID"); } }
rfid.halt(); }