0% found this document useful (0 votes)
20 views9 pages

Lamp Iran

Program Arduino
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views9 pages

Lamp Iran

Program Arduino
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

LAMPIRAN

#include <SPI.h>

#include <MFRC522.h>

#include <LiquidCrystal.h>

#include <Servo.h>

#define SS_PIN 10

#define RST_PIN 9

MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.

LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

Servo kunci;

int pos = 0;

int beep_pin = 16;

int beep_pinG = 17;

int switch_pin = 18;

int button_pin = 19;

int tutup = 14;

int buka = 15;

void setup()

Serial.begin(9600); // Initiate a serial communication

kunci.attach(8);

pinMode(switch_pin,INPUT_PULLUP);
pinMode(button_pin,INPUT_PULLUP);

pinMode(beep_pin,OUTPUT);

digitalWrite(beep_pin,LOW);

digitalWrite(beep_pinG,LOW);

pinMode(tutup,OUTPUT);

digitalWrite(tutup,HIGH);

pinMode(buka,OUTPUT);

digitalWrite(buka,HIGH);

kunci.write(0);

Serial.begin(9600);

lcd.begin(16, 2);

lcd.setCursor(3, 1);

lcd.print("Welcome!!");

lcd.setCursor(0, 0);

lcd.print("Circuit Siaaaap!");

delay(1500);

lcd.clear();

SPI.begin(); // Initiate SPI bus

mfrc522.PCD_Init(); // Initiate MFRC522

Serial.println("Put your card to the reader...");

Serial.println();

}
void loop()

digitalWrite(beep_pin, LOW);

digitalWrite(beep_pinG,LOW);

digitalWrite(tutup,HIGH);

digitalWrite(buka,HIGH);

kunci.write(0);

lcd.clear();

lcd.setCursor(0, 0);

lcd.print("Tempelkan Kartu");

lcd.setCursor(0, 1);

lcd.print("Akses tuk masuk!");

delay(100);

digitalWrite(beep_pinG,HIGH);

delay(200);

if (digitalRead(button_pin) == LOW || digitalRead(switch_pin) == LOW)

kunci.write(90);

delay(50);

digitalWrite(beep_pinG,LOW);

digitalWrite(beep_pin,HIGH);

delay(200);

digitalWrite(beep_pin,LOW);

delay(100);

lcd.setCursor(0, 0);

lcd.print(" PINTU TERBUKA!");


lcd.setCursor(0, 1);

lcd.print("+--------------+");

delay(300);

digitalWrite(tutup,LOW);

digitalWrite(buka,HIGH);

delay(1700);

digitalWrite(tutup,HIGH);

digitalWrite(buka,HIGH);

delay(2000);

do

digitalWrite(tutup,HIGH);

digitalWrite(buka,HIGH);

delay(500);

while(digitalRead(switch_pin) == LOW);

do

digitalWrite(tutup,HIGH);

digitalWrite(buka,HIGH);

delay(500);

while(digitalRead(switch_pin) == LOW);

do
{

digitalWrite(tutup,HIGH);

digitalWrite(buka,HIGH);

delay(500);

while(digitalRead(switch_pin) == LOW);

lcd.setCursor(0, 0);

lcd.print("+SELAMAT JALAN+");

lcd.setCursor(0, 1);

lcd.print("+HATI2 DI JALAN+");

delay(300);

digitalWrite(tutup,HIGH);

digitalWrite(buka,LOW);

delay(2000);

kunci.write(0);

delay(100);

// 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) == "55 11 A0 59" || content.substring(1) == "CF 88 74 0D" ||


content.substring(1) == "A2 80 57 7B") //change here the UID of the card/cards that you
want to give access

Serial.println("Authorized access");

kunci.write(90);

delay(50);
digitalWrite(beep_pinG,LOW);

digitalWrite(beep_pin,HIGH);

delay(200);

digitalWrite(beep_pin,LOW);

delay(100);

lcd.setCursor(0, 0);

lcd.print(" PINTU TERBUKA!");

lcd.setCursor(0, 1);

lcd.print("+--------------+");

delay(300);

digitalWrite(tutup,LOW);

digitalWrite(buka,HIGH);

delay(2000);

digitalWrite(tutup,HIGH);

digitalWrite(buka,HIGH);

delay(2000);

do

digitalWrite(tutup,HIGH);

digitalWrite(buka,HIGH);

delay(500);

while(digitalRead(switch_pin) == LOW);

do

{
digitalWrite(tutup,HIGH);

digitalWrite(buka,HIGH);

delay(500);

while(digitalRead(switch_pin) == LOW);

do

digitalWrite(tutup,HIGH);

digitalWrite(buka,HIGH);

delay(500);

while(digitalRead(switch_pin) == LOW);

lcd.setCursor(0, 0);

lcd.print("+SELAMAT JALAN+");

lcd.setCursor(0, 1);

lcd.print("+HATI2 DI JALAN+");

delay(300);

digitalWrite(tutup,HIGH);

digitalWrite(buka,LOW);

delay(2000);

kunci.write(0);

delay(100);

else {
digitalWrite(beep_pin,HIGH);

digitalWrite(beep_pinG,HIGH);

lcd.setCursor(0, 0);

lcd.print("ID : ");

lcd.print(content.substring(1));

lcd.setCursor(0, 1);

lcd.print("++Akes ditolak++");

Serial.println(" Access denied");

delay(1500);

You might also like