{"id":965,"date":"2018-06-21T19:46:28","date_gmt":"2018-06-21T19:46:28","guid":{"rendered":"https:\/\/zhutarduino.wordpress.com\/?page_id=965"},"modified":"2019-10-20T18:09:01","modified_gmt":"2019-10-20T18:09:01","slug":"learning-arduino-for-beginners-ep-35-keypads-and-the-password-library","status":"publish","type":"page","link":"https:\/\/thezhut.com\/?page_id=965","title":{"rendered":"Learning Arduino for beginners EP #35 keypads and the password Library"},"content":{"rendered":"<h1>In this episode we will take a look at how to use a keypad with the password library to make a password activated locking mechanism with your Arduino&#8230;<\/h1>\n<p><iframe loading=\"lazy\" title=\"Learning Arduino for beginners EP #35 keypads and the password Library\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/nA0mUQFLQBw?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<h2>Schematic:<\/h2>\n<p><a href=\"https:\/\/thezhut.com\/wp-content\/uploads\/2018\/06\/keypad.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-966\" src=\"https:\/\/thezhut.com\/wp-content\/uploads\/2018\/06\/keypad.jpg?w=300\" alt=\"\" width=\"633\" height=\"591\" srcset=\"https:\/\/thezhut.com\/wp-content\/uploads\/2018\/06\/keypad.jpg 894w, https:\/\/thezhut.com\/wp-content\/uploads\/2018\/06\/keypad-300x280.jpg 300w, https:\/\/thezhut.com\/wp-content\/uploads\/2018\/06\/keypad-768x716.jpg 768w\" sizes=\"auto, (max-width: 633px) 100vw, 633px\" \/><\/a><\/p>\n<h2>Parts List:<\/h2>\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=d8c0a3a84bd1a5474ff798c9777c8096\" target=\"_blank\" rel=\"noopener noreferrer\">Arduino<\/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 rgb led&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=0865c266c1b6dfec51298a74e7672850\" target=\"_blank\" rel=\"noopener noreferrer\">RGB<\/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=b36601356d857de3f907c98d38143279\" 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=arduino keypad&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=d8892425c58e0514ede3e721c01e03ce\" target=\"_blank\" rel=\"noopener noreferrer\">Keypad<\/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=220 resistor&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=aa2b43b4f8b8a2fa034c26de40a60426\" target=\"_blank\" rel=\"noopener noreferrer\">220\u03a9 resistor<\/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 breadboard&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=0e9bc696f4d13cda5b8e9a8ec2fac16d\" 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=0c75c2f4067343c01d3e0a1a2b9af8ab\" target=\"_blank\" rel=\"noopener noreferrer\">Jumper wires<\/a><\/p>\n<h2><\/h2>\n<h2>Arduino Code:<\/h2>\n<p>#define red 13<br \/>\n#define lock 12 \/\/ green<br \/>\n#define blue 11<br \/>\n#include &lt;Password.h&gt;<br \/>\n#include &lt;Keypad.h&gt;<br \/>\nPassword password = Password (&#8220;123A&#8221;);<br \/>\nconst byte ROWS = 4;<br \/>\nconst byte COLS = 4;<br \/>\nchar keys[ROWS][COLS] = {<br \/>\n{&#8216;1&#8242;,&#8217;2&#8242;,&#8217;3&#8242;,&#8217;A&#8217;},<br \/>\n{&#8216;4&#8242;,&#8217;5&#8242;,&#8217;6&#8242;,&#8217;B&#8217;},<br \/>\n{&#8216;7&#8242;,&#8217;8&#8242;,&#8217;9&#8242;,&#8217;C&#8217;},<br \/>\n{&#8216;*&#8217;,&#8217;0&#8242;,&#8217;#&#8217;,&#8217;D&#8217;}<br \/>\n};<br \/>\nbyte rowPins[ROWS] = {9, 8, 7, 6}; \/\/connect to the row pinouts of the keypad<br \/>\nbyte colPins[COLS] = {5, 4, 3, 2}; \/\/connect to the column pinouts of the keypad<br \/>\nKeypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );<\/p>\n<p>void setup()<br \/>\n{<br \/>\npinMode(red,OUTPUT);<br \/>\npinMode(lock,OUTPUT);<br \/>\npinMode(blue,OUTPUT);<br \/>\ndigitalWrite(blue,HIGH);<br \/>\nkeypad.addEventListener(keypadEvent);<\/p>\n<p>}<\/p>\n<p>void loop()<br \/>\n{<br \/>\nkeypad.getKey();<br \/>\n}<\/p>\n<p>void keypadEvent(KeypadEvent eKey)<br \/>\n{<br \/>\nswitch (keypad.getState())<br \/>\n{<br \/>\ncase PRESSED:<br \/>\nswitch (eKey)<br \/>\n{<br \/>\ncase &#8216;*&#8217;: checkPassword(); break;<br \/>\ncase &#8216;#&#8217;: password.reset(); break;<br \/>\ndefault: password.append(eKey);<br \/>\n}<br \/>\n}<br \/>\n}<\/p>\n<p>void checkPassword()<br \/>\n{<br \/>\nif (password.evaluate())<br \/>\n{<br \/>\ndigitalWrite(blue,LOW);<br \/>\ndigitalWrite(lock,HIGH);<br \/>\ndelay(2000);<br \/>\ndigitalWrite(lock,LOW);<br \/>\ndigitalWrite(blue,HIGH);<br \/>\npassword.reset();<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\ndigitalWrite(blue,LOW);<br \/>\ndigitalWrite(red,HIGH);<br \/>\ndelay(2000);<br \/>\ndigitalWrite(red,LOW);<br \/>\ndigitalWrite(blue,HIGH);<br \/>\npassword.reset();<br \/>\n}<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this episode we will take a look at how to use a keypad with the password library to make a password activated locking mechanism with your Arduino&#8230; Schematic: Parts List: affiliate links Arduino RGB Relay Keypad 220\u03a9 resistor Bread &hellip; <a href=\"https:\/\/thezhut.com\/?page_id=965\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":809,"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-965","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/965","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=965"}],"version-history":[{"count":3,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/965\/revisions"}],"predecessor-version":[{"id":1469,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/965\/revisions\/1469"}],"up":[{"embeddable":true,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/809"}],"wp:attachment":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}