Posted on Leave a comment

Sistem Parkir KENDARAAN dengan RFID dan Arduino UNO R3

Berikut ini KlinikRobot.com memberikan contoh pembuatan sistem parkir (portal/ palang) dapat juga dimodifikasi untuk pagar rumah/ pintu. Alat yang diperlukan cukup sederhana yaitu :

  • Arduino UNO R3 (Item No. KR03027)
  • RFID Reader RC522 (Item No. KR06066)
  • Character LCD 20X4 (Item No. KR07062)
  • I2C Module for LCD 20×4/ 16×2 (Item No. KR07099)
  • Buzzer (Item No. KR07064)
  • Micro Servo (Item No. KR16008)
  • 140Pcs Kabel Jumper set (Item No. KR04004)
Aplikasi Sistem Parkir dengan RFID menggunakan Arduino UNO R3

Demo Video :

Langkah-langkah pembuatan aplikasi sebagai berikut :

Rangkaian elektronik 

1. Rangkai Koneksi antara I2C module dengan LCD 20×4 dengan cara disolder.

2. Rangkai Koneksi antara I2C module dengan Arduino UNO sbb :

  • Pin Gnd (dari I2C module) ke GND (Arduino UNO R3)
  • Pin Vcc (dari I2C module) ke 5Volt (Arduino UNO R3)
  • Pin SDA (dari I2C module) ke A4 (Analog In ~ Arduino UNO R3)
  • Pin SCL (dari I2C module) ke A5 (Analog In ~ Arduino UNO R3)

3. Rangkai Koneksi antara RFID module dengan Arduino UNO sbb :

  • Pin 3.3V (dari RFID module) ke 3.3V (Arduino UNO R3)
  • Pin RST (dari RFID module) ke 5 (Digital ~ Arduino UNO R3)
  • Pin Gnd (dari RFID module) ke GND (Arduino UNO R3)
  • Pin MISO (dari RFID module) ke 12 (Digital ~ Arduino UNO R3)
  • Pin MOSI (dari RFID module) ke 11 (Digital ~ Arduino UNO R3)
  • Pin SCK (dari RFID module) ke 13 (Digital ~ Arduino UNO R3)
  • Pin SDA (dari RFID module) ke 10 (Digital ~ Arduino UNO R3)

5. Rangkai Koneksi antara Buzzer dengan Arduino UNO sbb :

  • Kutub (+) dari Buzzer ke 8 (Digital ~ Arduino UNO R3)
  • Kutub (-)/GND dari Buzzer ke GND (Arduino UNO R3)

6. Rangkai Koneksi antara Servo dengan Arduino UNO sbb :

  • Pin Signal (dari servo) ke 6 (Digital ~ Arduino UNO R3)
  • Pin Vcc (dari servo) ke 5Volt (Arduino UNO R3)
  • Pin Gnd (dari Servo ke GND (Arduino UNO R3)

7. Power supply (untuk pengetesan cukup dengan USB dari PC ke Arduino UNO R3)

Instalasi Library RFID di Arduino IDE :

1. Unduh library RFID disini : klik sini

2. Ekstrak file yang di-unduh ke folder : Arduino/libraries/folder yang diekstrak

Script code untuk pemrograman :

// libraries
#include <SPI.h>
#include <RFID.h>
#include <Servo.h>
#include “pitches.h”
#include <LiquidCrystal_I2C.h>
#include <Wire.h>

// RFID definition
RFID rfid(10,5);

 // Kode Kartu RFID : misal kartu dibaca 95E3C3E550, dituliskan sbb : 0x95,0xE3,0xC3,0xE5,0x50
byte emaomos[5] = {0x95,0xE3,0xC3,0xE5,0x50};

// // LCD address and type declaration
LiquidCrystal_I2C lcd(0x27,20,4);

byte serNum[5];
byte data[5];

// Melodies definition: access, welcome and rejection
int access_melody[] = {NOTE_G4,0,NOTE_A4,0, NOTE_B4,0,NOTE_A4,0,NOTE_B4,0, NOTE_C5,0};
int access_noteDurations[] = {8,8,8,8,8,4,8,8,8,8,8,4};
int fail_melody[] = {NOTE_G2,0,NOTE_F2,0,NOTE_D2,0};
int fail_noteDurations[] = {8,8,8,8,8,4};

// pins definition – LED, Buzzer and Servo-motor
int LED_access = 3;
int LED_intruder = 4;
int speaker_pin = 8;
int servoPin = 6;

// servo motor definition
Servo doorLock;

void setup(){
  doorLock.attach(servoPin); // servo motor attaching
  Serial.begin(9600); // Serial communication initialization
  lcd.init(); // LCD initialization
  lcd.backlight();
  lcd.clear();// Clears the LCD display
  SPI.begin(); // SPI communication initialization
  rfid.init(); // RFID module initialization
  Serial.println(“+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”);
  Serial.println(“+ SISTEM KENDALI GERBANG PERUMAHAN GRAHA RAYA – CLUSTER FORTUNE SPRING                +”); 
  Serial.println(“+ Versi 1.0.0 September 2015 Created by KlinikRobot.com +”);
  Serial.println(“+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”);
  delay(1000);
  pinMode(LED_access,OUTPUT);
  pinMode(LED_intruder,OUTPUT);
  pinMode(speaker_pin,OUTPUT);
  pinMode(servoPin,OUTPUT);
}
 
void loop(){
  lcd.clear();
  lcd.noBacklight();
  // Here you can create a variable for each user
  // NAME_card ou KEY_card
  boolean emaomos_card = true; // that is my card (e + mao + mos)…e + marcelo = mao, moraes = mos
  
  if (rfid.isCard()){ // valid card found
    if (rfid.readCardSerial()){ // reads the card
      delay(1000);
      data[0] = rfid.serNum[0]; // stores the serial number
      data[1] = rfid.serNum[1];
      data[2] = rfid.serNum[2];
      data[3] = rfid.serNum[3];
      data[4] = rfid.serNum[4];
    }
  
  //rfid.halt(); // RFID module to standby
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print(”    ID DI-BACA:”);
  //Serial.print(“Card found – code:”);
  lcd.setCursor(0,1);
  lcd.print(”     “);
  if(rfid.serNum[0] < 16){
    lcd.print(“0”);
  }
  lcd.print(rfid.serNum[0],HEX);
  
  if(rfid.serNum[1] < 16){
    lcd.print(“0”);
  }
  lcd.print(rfid.serNum[1],HEX);
  
  if(rfid.serNum[2] < 16){
    lcd.print(“0”);
  }
  lcd.print(rfid.serNum[2],HEX);
  
  if(rfid.serNum[3] < 16){
    lcd.print(“0”);
  }
  lcd.print(rfid.serNum[3],HEX);
  
  if(rfid.serNum[4] < 16){
    lcd.print(“0”);
  }
  lcd.print(rfid.serNum[4],HEX);
  
  for(int i=0; i<5; i++){
    if(data[i] != emaomos[i]) emaomos_card = false; // if it is not a valid card, put false to this user
    // Here you can check the another allowed users, just put lines like above with the user name
  }
  Serial.println();
  if (emaomos_card){ // if a valid card was found
    lcd.setCursor(0,2);
    lcd.print(”  Sedang Proses…  “);
    //Serial.println(“Hello user Marcelo!”); // print a message
    for (int i = 0; i < 12; i++){ // play welcome sound
      int access_noteDuration = 1000/access_noteDurations[i];
      tone(speaker_pin, access_melody[i],access_noteDuration);
      int access_pauseBetweenNotes = access_noteDuration * 1.30;
      delay(access_pauseBetweenNotes);
      noTone(speaker_pin);
    }
  }
  /*
  // another cards analysis put many blocks like this as many user you have
  else if(USER_card){// put the another allowed user here
    lcd.setCursor(0,3);
    lcd.print(“Hello USER NAME”);
    //Serial.println(“Hello USER NAME”); // put the user name in the “USER NAME”
    for (int i = 0; i < 12; i++){
      int access_noteDuration = 1000/access_noteDurations[i];
      tone(speaker_pin, access_melody[i],access_noteDuration);
      int access_pauseBetweenNotes = access_noteDuration * 1.30;
      delay(access_pauseBetweenNotes);
      noTone(speaker_pin);
    }
  }
  */
  else{ // if a card is not recognized
    lcd.setCursor(0,2);
    lcd.print(” ID TIDAK DIKENAL!”);
    lcd.setCursor(0,3);
    lcd.print(”   AKSES DITOLAK!”);
    //Serial.println(“Card not recognized!  contact administration!”); // print a message
    digitalWrite(LED_intruder, HIGH); // turn on the red LED
    for (int i = 0; i < 6; i++){ // playa rejection sound
      int fail_noteDuration = 1000/fail_noteDurations[i];
      tone(speaker_pin, fail_melody[i],fail_noteDuration);
      int fail_pauseBetweenNotes = fail_noteDuration * 1.30;
      delay(fail_pauseBetweenNotes);
      noTone(speaker_pin);
    }
    delay(1000);
    digitalWrite(LED_intruder, LOW); // turn off the red LED
  }
  if (emaomos_card){// add another user using an logical or condition ||
    // Welcome messages and access permission  
    lcd.setCursor(0,2);
    lcd.print(”  Access DITERIMA!”);
    lcd.setCursor(0,3);
    lcd.print(”   W E L C O M E!”);
    //Serial.println(“Access Granted!… Welcome to ArduinoByMySelf!”); // print a message
    digitalWrite(LED_access,HIGH); // turn on the green LED
    doorLock.write(90); // releases the door
    delay(5000); // wait
    doorLock.write(0); // Locks the door
    digitalWrite(LED_access,LOW); // turn off the green LED
  }
  Serial.println();
  delay(500);
  rfid.halt();
  lcd.noBacklight();
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *