Translate

Membuat Alat Pengunci Pintu Otomatis ( Door Lock ) Menggunakan RFID Reader ID-12

Membuat Alat Pengunci Pintu Otomatis ( Door Lock ) Menggunakan RFID Reader ID-12


              Pada sore hari ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang bisa digunakan untuk mengunci pintu secara otomatis dengan kunci berupa kartu atau sejenisnya, jadi alat ini adalah alat inovasi pengganti kunci konvensional yang biasanya diputar atau digeser. Alat ini memiliki 3 unsur penyusun utama, yaitu RFID reader, tag card dan kontroller, RFID reader yang dipakai adalah ID-12, kemudian tag card nya menggunakan tag card bernentuk kartu dan kontrollernya adalah ATMega16. Pengunci pintu menggunakan solenoid door lock dengan tegangan aktif 12 volt dc. Untuk lebih jelasnya berikut adalah skema dan programnya.


a. Minimum System




b. Solenoid Door Lock + Driver 12 volt




c. RFID Reader ID-12




d. Tag card




e. Program Bascom AVR

$regfile = "m16def.dat"
$crystal = 11059200
$baud = 9600

Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.2 , Db4 = Portc.4
Config Lcdpin = Pin , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7
Config Lcd = 16 * 2

Cls
Cursor Off

Dim Y As String * 20 , Id As String * 20
Dim X As Integer

Config Sda = Portd.2
Config Scl = Portd.3

Const Ds1307w = &HD0
Const Ds1307r = &HD1

Dim _sec As Byte
Dim _min As Byte
Dim _hour As Byte
Dim _day As Byte
Dim _month As Byte
Dim _year As Byte
Dim _weekday As Byte

Dim Sa(3) As String * 2
Dim Sb(3) As String * 2

Declare Sub Getdatetime
Declare Sub Settime
Declare Sub Getsec
Declare Sub Disptime
Declare Sub Dispdate
Declare Sub Format_00
Declare Sub Setdate
Declare Sub Subset

Dim I As Byte
Dim Flagset As Bit              '0 = Waktu, 1 = Tanggal
Dim Flagreset As Bit
Dim Line1 As String * 1

Dim Weekday As Byte
Dim Jam_puluhan As Integer
Dim Jam_satuan As Integer
Dim Min_puluhan As Integer
Dim Min_satuan As Integer
Dim Sec_puluhan As Integer
Dim Sec_satuan As Integer

Ddrd.4 = 1
Ddrb.4 = 0
Portb.4 = 1


'_sec = 00
'_hour = 11
'_min = 20
'Settime

'_day = 14
'_month = 12
'_year = 15
'Setdate

I = 13
Line1 = Chr(13)

Portd.4 = 0

Main:

Do

If Pinb.4 = 0 Then
Portd.4 = 1
Wait 3
Else
Portd.4 = 0
End If

Locate 1 , 1
Lcd "Dekatkan Kartu"

Y = Inkey()

If Pinb.4 = 0 Then
Portd.4 = 1
Wait 3
Else
Portd.4 = 0
End If

If Y <> "" Then
Input Y Noecho
Id = Mid(y , 3 , 13)
Cls
Cursor Off

Getdatetime

Locate 1 , 1
Disptime

If Id = "6F0085C00923" Then
Locate 2 , 1
Lcd "Era Wahyudi"
Portd.4 = 1
Else
Goto Main

End If

'Locate 2 , 1
'Lcd Id

Wait 3
Cls
Else
Goto Main

End If

portd.4 = 0

Loop

Sub Getdatetime:

I2cstart                                                    ' Generate start code
I2cwbyte Ds1307w                                            ' send address

I2cwbyte 0                                                  ' start address in 1307

I2cstart                                                    ' Generate start code
I2cwbyte Ds1307r                                            ' send address

I2crbyte _sec , Ack
I2crbyte _min , Ack                                         ' MINUTES
I2crbyte _hour , Ack                                        ' Hours
I2crbyte _weekday , Ack                                     ' Day of Week
I2crbyte _day , Ack                                         ' Day of Month
I2crbyte _month , Ack                                       ' Month of Year
I2crbyte _year , Nack                                       ' Year

I2cstop

_sec = Makedec(_sec) : _min = Makedec(_min) : _hour = Makedec(_hour)
_day = Makedec(_day) : _month = Makedec(_month) : _year = Makedec(_year)
End Sub

Sub Settime:
_sec = Makebcd(_sec) : _min = Makebcd(_min) : _hour = Makebcd(_hour)

I2cstart                                                    ' Generate start code
I2cwbyte Ds1307w                                            ' send address
I2cwbyte 0                                                  ' starting address in 1307
I2cwbyte _sec                                               ' Send Data to SECONDS
I2cwbyte _min                                               ' MINUTES
I2cwbyte _hour                                              ' Hours
I2cstop

End Sub

Sub Setdate

_day = Makebcd(_day) : _month = Makebcd(_month) : _year = Makebcd(_year)

I2cstart                                                    ' Generate start code
I2cwbyte Ds1307w                                            ' send address
I2cwbyte 4                                                  ' starting address in 1307
I2cwbyte _day                                               ' Send Data to SECONDS
I2cwbyte _month                                             ' MINUTES
I2cwbyte _year                                              ' Hours
I2cstop

End Sub
Sub Dispdate
Sa(1) = Str(_day)
Sa(2) = Str(_month)
Sa(3) = Str(_year)
Format_00
Lcd "Date: " ; Sb(1) ; "-" ; Sb(2) ; "-" ; Sb(3)
End Sub


Sub Disptime
Sa(1) = Str(_hour)
Sa(2) = Str(_min)
Sa(3) = Str(_sec)
Format_00
Lcd "Time: " ; Sb(1) ; ":" ; Sb(2) ; ":" ; Sb(3)
End Sub

Sub Format_00
For I = 1 To 3 Step 1
Sb(i) = Format(sa(i) , "00")
Next I
End Sub



 

f. VIDEO HASILNYA














No comments:

Post a Comment