{"id":1054,"date":"2018-10-27T23:08:13","date_gmt":"2018-10-27T23:08:13","guid":{"rendered":"https:\/\/zhutarduino.wordpress.com\/?page_id=1054"},"modified":"2019-10-20T16:36:25","modified_gmt":"2019-10-20T16:36:25","slug":"arduino-mad-scientist-laboratory-ep-7-rfid-keyless-entry","status":"publish","type":"page","link":"https:\/\/thezhut.com\/?page_id=1054","title":{"rendered":"Arduino Mad Scientist Laboratory EP #7 RFID keyless entry"},"content":{"rendered":"<h1 style=\"text-align: center;\">Today we will be attempting to take over the world by building a RFID keyless lock system.<\/h1>\n<p><iframe loading=\"lazy\" title=\"Arduino Mad Scientist Laboratory EP #7 RFID keyless entry\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/zLgi9POX8nE?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<p>&nbsp;<\/p>\n<h1><a href=\"https:\/\/www.facebook.com\/zarduino\/\" target=\"_blank\" rel=\"noopener noreferrer\">Check us out on Facebook!<\/a><\/h1>\n<h1>RC522 Library:<\/h1>\n<p><a href=\"http:\/\/playground.arduino.cc\/Learning\/MFRC522\" target=\"_blank\" rel=\"noopener noreferrer\">CLICK HERE FOR LIBRARY<\/a><\/p>\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 Nano Board&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=da55004852a6f01f32fc844eba4254c9\" target=\"_blank\" rel=\"noopener noreferrer\">Arduino Nano Board<\/a><\/p>\n<div class=\"item-spec-r\">\n<h4 class=\"item-spec item-title-wrap\"><a href=\"https:\/\/www.amazon.com\/gp\/search\/ref=as_li_qf_sp_sr_il_tl?ie=UTF8&amp;tag=zhut01-20&amp;keywords=Nano Terminal Adapter&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=910bd4e2465a6d6d4f944ad2ca2935e0\" target=\"_blank\" rel=\"noopener noreferrer\">Nano Terminal Adapter<\/a><\/h4>\n<\/div>\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=solenoid lock&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=557a6bac2ad9cc809aa4c9efa93359e0\" target=\"_blank\" rel=\"noopener noreferrer\">solenoid Lock<\/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=TIP120&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=76196dafdaee9b1127794f54b7919d54\" target=\"_blank\" rel=\"noopener noreferrer\">TIP120<\/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=rc522&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=4196507b1026977d8e575fb3d3a0d8d7\" target=\"_blank\" rel=\"noopener noreferrer\">Rfid Card Reader (RC522)<\/a><\/p>\n<p>Wire<\/p>\n<p>project enclosures<\/p>\n<p>&nbsp;<\/p>\n<h1>SCHEMATIC:<\/h1>\n<p><a href=\"https:\/\/thezhut.com\/wp-content\/uploads\/2018\/10\/rfid_schematic.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1055\" src=\"https:\/\/thezhut.com\/wp-content\/uploads\/2018\/10\/rfid_schematic.jpg?w=288\" alt=\"\" width=\"640\" height=\"667\" srcset=\"https:\/\/thezhut.com\/wp-content\/uploads\/2018\/10\/rfid_schematic.jpg 951w, https:\/\/thezhut.com\/wp-content\/uploads\/2018\/10\/rfid_schematic-288x300.jpg 288w, https:\/\/thezhut.com\/wp-content\/uploads\/2018\/10\/rfid_schematic-768x799.jpg 768w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h1>ARDUINO CODE:<\/h1>\n<p>#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;yout tag id here&#8221;; \/\/ put your rfid tags code here<br \/>\nString ok_rfid_2 = &#8220;your tag id here&#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 or solenoid 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}<\/p>\n<p>void 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 hapen<\/p>\n<p>digitalWrite(green, HIGH);<br \/>\ndigitalWrite(relay, HIGH);<br \/>\ndelay(5000); \/\/ how long the relay wil be on<br \/>\ndigitalWrite(green, LOW);<br \/>\ndigitalWrite(relay, LOW);<\/p>\n<p>}<\/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>Today we will be attempting to take over the world by building a RFID keyless lock system. &nbsp; Check us out on Facebook! RC522 Library: CLICK HERE FOR LIBRARY PARTS LIST: affiliate links Arduino Nano Board Nano Terminal Adapter solenoid &hellip; <a href=\"https:\/\/thezhut.com\/?page_id=1054\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":1009,"menu_order":6,"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-1054","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/1054","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=1054"}],"version-history":[{"count":2,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/1054\/revisions"}],"predecessor-version":[{"id":1464,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/1054\/revisions\/1464"}],"up":[{"embeddable":true,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/1009"}],"wp:attachment":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}