Nama : Muh. Fachrul Alam NIM : D42116520
SISTEM KUNCI PINTU OTOMATIS MENGGUNAKAN RFID Alat dan bahan : 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.
Arduino RFID RC522 Modul Relay Adaptor 12V 1A Solenoid Doorlock Kabel Jumper LCD 16x2 Modul I2C Bread Board Buzzer
Langkah langkah pengerjaannya :
1. Sambungkan arduino dengan RFID RC522 nya. Pin 3.3 Volt arduino ke 3.3 Volt RFID, Pin Gnd arduino ke Gnd RFID, Pin RST ke Pin 9 arduino, Pin SDA ke Pin 10 arduino, Pin MOSI ke Pin 11 arduino, Pin MISO ke Pin 12 arduino, Pin SCK ke Pin 13 arduino. 2. Pasang I2C modul ke LCD 16X4. Sambungan VCC 12C ke 5V arduino, Gnd I2C ke Gnd arduino, Pin SDA ke Pin A4 arduino, Pin SCL ke Pin A5 arduino. 3. Sambungkan modul buzzer KY-012 ke VCC 5 Volt arduino, Gnd KY-012 ke Gnd arduino, Pin S KY-012 ke Pin 6 arduino. 4. Siapkan modul relay, sambungkan 5 volt modul relay ke 5 volt arduino, Gnd relay ke Gnd arduino, IN1 relay ke Pin 6 arduino. 5. Sambungkan + batre/adaptor ke outputan relay. Sambungkan + dari doorlock ke common relay. 6. Sambungkan - doorlock ke – adaptor
7. Masukkan program RFID, ubah bagian UID Card sesuaikan ID number nya. Upload program ke arduino lewat pc, tunggu sampai programnya selesai terupload. Berikut list programnya..
Isi kode arduino :
#include <SPI.h> #include <MFRC522.h> #include <Wire.h> #include #define SS_PIN 10 #define RST_PIN 9 MFRC522 mfrc522(SS_PIN, RST_PIN); int pinBuzzer = 8; int doorLock = 6; LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); void setup() { Serial.begin(9600); // Initiate a serial communication SPI.begin(); // Initiate SPI bus mfrc522.PCD_Init(); // Initiate MFRC522 pinMode(pinBuzzer, OUTPUT); pinMode(doorLock, OUTPUT); digitalWrite(pinBuzzer, HIGH); // set up the LCD's number of columns and rows: lcd.begin(20, 4); lcd.backlight(); delay(250); lcd.noBacklight(); delay(250); lcd.backlight(); lcd.clear(); lcd.setCursor(0,1); lcd.print(" Insert Your"); delay(300); lcd.setCursor(0,2); lcd.print(" ID CARD"); delay(500); }
void loop() { lcd.display(); delay(500);
// Look for new cards if ( ! mfrc522.PICC_IsNewCardPresent()) { return; } //Select one of the cards if ( ! mfrc522.PICC_ReadCardSerial()) { return; } //Show UID on serial monitor lcd.setCursor(0,0); Serial.print("UID tag :"); lcd.print("UID:"); String content= ""; byte letter; for (byte i = 0; i < mfrc522.uid.size; i++) { Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); Serial.print(mfrc522.uid.uidByte[i], HEX); lcd.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); lcd.print(mfrc522.uid.uidByte[i], HEX); content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ")); content.concat(String(mfrc522.uid.uidByte[i], HEX)); } lcd.print(" Message : "); content.toUpperCase(); if (content.substring(1) =="50 2B 06 10") //rubah UID nya disini sesuai ID card yang boleh di access { lcd.clear(); lcd.setCursor(0,1); lcd.print(" Hai"); delay(300); lcd.setCursor(0,2); lcd.print(" Selamat Datang"); delay(500); digitalWrite(pinBuzzer, LOW); delay(500); digitalWrite(pinBuzzer, HIGH); delay(500); digitalWrite(doorLock, HIGH); lcd.clear(); lcd.setCursor (0,1); lcd.print(F(" Silahkan Masuk ")); lcd.setCursor (0,2); lcd.print(F(" AutoLock after ")); for(int i=5; i>0; i--) {
lcd.setCursor (17,2); lcd.print(i); delay (1000); } digitalWrite(doorLock, LOW); digitalWrite(pinBuzzer, HIGH); lcd.clear(); lcd.setCursor(0,1); lcd.print(" Insert Your"); delay(300); lcd.setCursor(0,2); lcd.print(" ID CARD"); delay(500); } else { lcd.setCursor(0,2); lcd.clear(); lcd.print(" Access Denied "); delay(500); digitalWrite(pinBuzzer, HIGH); delay(300); digitalWrite(pinBuzzer, LOW); delay(300); digitalWrite(pinBuzzer, HIGH); delay(300); digitalWrite(pinBuzzer, LOW); delay(300); digitalWrite(pinBuzzer, HIGH); delay(300); digitalWrite(pinBuzzer, LOW); delay(300); digitalWrite(pinBuzzer, HIGH); delay(1000); lcd.clear(); lcd.setCursor(0,1); lcd.print(" Insert Your"); delay(300); lcd.setCursor(0,2); lcd.print(" ID CARD"); delay(500); } }