{"id":490,"date":"2017-01-27T20:02:33","date_gmt":"2017-01-27T20:02:33","guid":{"rendered":"https:\/\/zhutarduino.wordpress.com\/?page_id=490"},"modified":"2020-10-12T16:33:30","modified_gmt":"2020-10-12T16:33:30","slug":"how-to-make-a-arduino-controlled-rfid-keyless-entry-door-lock","status":"publish","type":"page","link":"https:\/\/thezhut.com\/?page_id=490","title":{"rendered":"How to make a ARDUINO controlled RFID keyless entry door lock"},"content":{"rendered":"<h1>This tutorial will show you how to use a ARDUINO with a RC522 (MFRC522) RFID card reader to make a keyless entry door lock system..<\/h1>\n<p>Click on video below for full tutorial&#8230;<\/p>\n<p><iframe loading=\"lazy\" title=\"How to make a ARDUINO controlled RFID keyless entry door lock system\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/2mBF9GDuBjo?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<h1><\/h1>\n<h1><a href=\"https:\/\/www.facebook.com\/zarduino\/\"><strong><span style=\"color: #ff0000;\">Check us out on Facebook!<\/span><\/strong><\/a><\/h1>\n<h1><a href=\"http:\/\/playground.arduino.cc\/Learning\/MFRC522\" target=\"_blank\" rel=\"noopener noreferrer\">Click here to get the\u00a0MFRC522 library<\/a><\/h1>\n<h1>PARTS LIST:<\/h1>\n<p>#affiliate links#<\/p>\n<p><a href=\"https:\/\/www.amazon.com\/gp\/search\/ref=as_li_qf_sp_sr_il_tl?ie=UTF8&amp;tag=zhut01-20&amp;keywords=arduino board&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=ff032c24e1afc051e4635d3cf27a611f\" target=\"_blank\" rel=\"noopener noreferrer\">ARDUINO board<\/a><\/p>\n<p><a href=\"https:\/\/www.amazon.com\/gp\/search\/ref=as_li_qf_sp_sr_il_tl?ie=UTF8&amp;tag=zhut01-20&amp;keywords=mfrc522&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=9fb8687cd666f8dc50e8b25cc114af85\" target=\"_blank\" rel=\"noopener noreferrer\">RFID reader<\/a><\/p>\n<p><a href=\"https:\/\/www.amazon.com\/gp\/search\/ref=as_li_qf_sp_sr_il_tl?ie=UTF8&amp;tag=zhut01-20&amp;keywords=arduino relay&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=b2983b56acb562526709dee66d838eb6\" target=\"_blank\" rel=\"noopener noreferrer\">Relay<\/a><\/p>\n<p><a href=\"https:\/\/www.amazon.com\/gp\/search\/ref=as_li_qf_sp_sr_il_tl?ie=UTF8&amp;tag=zhut01-20&amp;keywords=Door Lock solenoid&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=ddeb2a7e6e1cec809e130f4092f8cde2\" target=\"_blank\" rel=\"noopener noreferrer\">Door Lock solenoid<\/a><\/p>\n<p><a href=\"https:\/\/www.amazon.com\/gp\/search\/ref=as_li_qf_sp_sr_il_tl?ie=UTF8&amp;tag=zhut01-20&amp;keywords=logic level converter&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=0d5b85c5d23d3ebb0134959162f90043\" target=\"_blank\" rel=\"noopener noreferrer\">Logic LVL Converter<\/a><\/p>\n<p><a href=\"https:\/\/www.amazon.com\/gp\/search\/ref=as_li_qf_sp_sr_il_tl?ie=UTF8&amp;tag=zhut01-20&amp;keywords=rgb led&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=bc68c8a1d83bcc73f0f69869dad5310e\" target=\"_blank\" rel=\"noopener noreferrer\">RGB LED<\/a><\/p>\n<p><a href=\"https:\/\/www.amazon.com\/gp\/search\/ref=as_li_qf_sp_sr_il_tl?ie=UTF8&amp;tag=zhut01-20&amp;keywords=resistors&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=9e1a19cedad4950fbab1c5047acc89d9\" target=\"_blank\" rel=\"noopener noreferrer\">1 X resistor (value depends on led you use)<\/a><\/p>\n<p><a href=\"https:\/\/www.amazon.com\/gp\/search\/ref=as_li_qf_sp_sr_il_tl?ie=UTF8&amp;tag=zhut01-20&amp;keywords=arduino bread board&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=9f77681391141f06dab730d002313a3c\" target=\"_blank\" rel=\"noopener noreferrer\">Bread Board<\/a><\/p>\n<p><a href=\"https:\/\/www.amazon.com\/gp\/search\/ref=as_li_qf_sp_sr_il_tl?ie=UTF8&amp;tag=zhut01-20&amp;keywords=arduino jumper wires&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=edb6ac08024c48c87a6d6a422b3f55f8\" target=\"_blank\" rel=\"noopener noreferrer\">Jumper Wires<\/a><\/p>\n<h1>SCHEMATIC:<\/h1>\n<p>click on image to enlarge it, you can also print it.<\/p>\n<p><a href=\"https:\/\/thezhut.com\/wp-content\/uploads\/2017\/01\/rfid_door_lock_schem.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-498\" src=\"https:\/\/thezhut.com\/wp-content\/uploads\/2017\/01\/rfid_door_lock_schem.jpg?w=300\" alt=\"rfid_door_lock_schem\" width=\"669\" height=\"339\" srcset=\"https:\/\/thezhut.com\/wp-content\/uploads\/2017\/01\/rfid_door_lock_schem.jpg 1689w, https:\/\/thezhut.com\/wp-content\/uploads\/2017\/01\/rfid_door_lock_schem-300x152.jpg 300w, https:\/\/thezhut.com\/wp-content\/uploads\/2017\/01\/rfid_door_lock_schem-768x389.jpg 768w, https:\/\/thezhut.com\/wp-content\/uploads\/2017\/01\/rfid_door_lock_schem-1024x518.jpg 1024w\" sizes=\"auto, (max-width: 669px) 100vw, 669px\" \/><\/a><\/p>\n<h1>ARDUINO CODE:<\/h1>\n<p>\/*<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nTypical pin layout used:<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\nMFRC522 Arduino Arduino Arduino Arduino Arduino<br \/>\nReader\/PCD Uno Mega Nano v3 Leonardo\/Micro Pro Micro<br \/>\nSignal Pin Pin Pin Pin Pin Pin<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\nRST\/Reset RST 9 5 D9 RESET\/ICSP-5 RST<br \/>\nSPI SS SDA(SS) 10 53 D10 10 10<br \/>\nSPI MOSI MOSI 11 \/ ICSP-4 51 D11 ICSP-4 16<br \/>\nSPI MISO MISO 12 \/ ICSP-1 50 D12 ICSP-1 14<br \/>\nSPI SCK SCK 13 \/ ICSP-3 52 D13 ICSP-3 15<\/p>\n<p>*\/<br \/>\n#include &lt;SPI.h&gt;<br \/>\n#include &lt;MFRC522.h&gt;<\/p>\n<p>#define RST_PIN 9 \/\/ Configurable, see typical pin layout above<br \/>\n#define SS_PIN 10 \/\/ Configurable, see typical pin layout above<\/p>\n<p>MFRC522 mfrc522(SS_PIN, RST_PIN); \/\/ Create MFRC522 instance.<\/p>\n<p>String read_rfid;<br \/>\nString ok_rfid_1 = &#8220;66f4608e&#8221;;<br \/>\nString ok_rfid_2 = &#8220;c08e3f52&#8221;; \/\/add as many as you need.<\/p>\n<p>#define red 4 \/\/ RGB led pins<br \/>\n#define green 3<br \/>\n#define relay 7 \/\/ Relay pin#<\/p>\n<p>void setup() {<br \/>\nSerial.begin(9600); \/\/ Initialize serial communications with the PC<br \/>\nSPI.begin(); \/\/ Init SPI bus<br \/>\nmfrc522.PCD_Init(); \/\/ Init MFRC522 card<br \/>\npinMode(red, OUTPUT);<br \/>\npinMode(green, OUTPUT);<br \/>\npinMode(relay, OUTPUT);<br \/>\n}<br \/>\nvoid dump_byte_array(byte *buffer, byte bufferSize) {<br \/>\nread_rfid = &#8220;&#8221;;<br \/>\nfor (byte i = 0; i &lt; bufferSize; i++) {<br \/>\nread_rfid = read_rfid + String(buffer[i], HEX);<br \/>\n}<br \/>\n}<\/p>\n<p>void open_lock() {<br \/>\n\/\/ if rfid is good this is what will happen<\/p>\n<p>digitalWrite(green, HIGH);<br \/>\ndigitalWrite(relay, HIGH);<br \/>\ndelay(5000); \/\/ how long the relay will be on<br \/>\ndigitalWrite(green, LOW);<br \/>\ndigitalWrite(relay, LOW);<br \/>\n}<\/p>\n<p>void loop() {<\/p>\n<p>\/\/ Look for new cards<br \/>\nif ( ! mfrc522.PICC_IsNewCardPresent())<br \/>\nreturn;<\/p>\n<p>\/\/ Select one of the cards<br \/>\nif ( ! mfrc522.PICC_ReadCardSerial())<br \/>\nreturn;<\/p>\n<p>dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);<br \/>\nSerial.println(read_rfid);<br \/>\nif (read_rfid == ok_rfid_1) { \/\/ RFID #1<br \/>\n\/\/ok, open the door.<br \/>\nopen_lock();<br \/>\n}<\/p>\n<p>if (read_rfid == ok_rfid_2) { \/\/ RFID #2<br \/>\n\/\/also ok, open the door<br \/>\nopen_lock();<br \/>\n}<\/p>\n<p>if (read_rfid != ok_rfid_1 &amp;&amp; read_rfid != ok_rfid_2)<br \/>\n{<br \/>\ndigitalWrite(red,HIGH);<br \/>\ndelay(2000);<br \/>\ndigitalWrite(red,LOW);<br \/>\n}<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial will show you how to use a ARDUINO with a RC522 (MFRC522) RFID card reader to make a keyless entry door lock system.. Click on video below for full tutorial&#8230; Check us out on Facebook! Click here to &hellip; <a href=\"https:\/\/thezhut.com\/?page_id=490\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":10,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":"","_links_to":"","_links_to_target":""},"class_list":["post-490","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/490","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/thezhut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=490"}],"version-history":[{"count":3,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/490\/revisions"}],"predecessor-version":[{"id":1600,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/490\/revisions\/1600"}],"up":[{"embeddable":true,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/10"}],"wp:attachment":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}