Bahan yang diperlukan:
-Arduino Uno 1buah
-RFID reader(generic) 1buah
-rtc ds1307 1buah
-Servo (tower pro MG996R) 1buah
-Breadboard 1buah
-jumper wires(generic) Secukupnya
-Buzzer 1buah
https://create.arduino.cc/projecthub/misbahul-ulum/pembuka-gerbang-otomatis-20ece5
CODING :
/*
- All the resources for this project: https://www.hackster.io/Aritro
#include
#include
#include
Servo servoku;
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
#include
#include “RTClib.h”
RTC_DS1307 RTC;
void setup()
{
Serial.begin(9600); // Initiate a serial communication
servoku.attach(9);
Wire.begin();
RTC.begin();
if (! RTC.isrunning()) {
Serial.println(“RTC is NOT running!”);
// following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(DATE, TIME));
}
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
Serial.println(“Dekatkan Tag”);
Serial.println();
pinMode(3, OUTPUT);
}
void loop()
{
DateTime now = RTC.now();
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
Serial.print(“UID tag :”);
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); content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? ” 0″ : ” “)); content.concat(String(mfrc522.uid.uidByte[i], HEX)); } Serial.println(); Serial.print(“Message : “); content.toUpperCase(); if (content.substring(1) == “42 5A A0 0D” && now.hour()<22 && now.hour()>5 || content.substring(1) == “59 1F 71 8B” && now.hour()<22 && now.hour()>5) //change here the UID of the card/cards that you want to give access
{
digitalWrite(3, HIGH);
delay(300);
digitalWrite(3, LOW);
servoku.write(0);
delay(3000);
servoku.write(90);
Serial.println("Akses diizinkan");
Serial.println();
delay(3000);
}
else {
Serial.println(” Akses ditolak”);
delay(3000);
}
}
jika ada kendala bisa diskusi di : 085369237896 (mas fajar)


