{"id":9202,"date":"2015-07-20T15:07:51","date_gmt":"2015-07-20T15:07:51","guid":{"rendered":"http:\/\/randomnerdtutorials.com\/?p=9202"},"modified":"2019-04-02T10:23:34","modified_gmt":"2019-04-02T10:23:34","slug":"arduino-membrane-keypad-tutorial","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/arduino-membrane-keypad-tutorial\/","title":{"rendered":"Arduino Membrane Keypad Tutorial"},"content":{"rendered":"<p>A keypad allows you to interact with a\u00a0microcontroller. You can salvage\u00a0these keypads from old telephones or you can purchase\u00a0them from most\u00a0electronics store for less than $2.<!--more--><\/p>\n<p><a href=\"http:\/\/ebay.to\/1Ie0JEE\" target=\"_blank\" rel=\"noopener noreferrer\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter wp-image-9205\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/07\/57.jpg?resize=412%2C232&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"$_57\" width=\"412\" height=\"232\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/07\/57.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/07\/57.jpg?w=869&amp;quality=100&amp;strip=all&amp;ssl=1 869w\" sizes=\"(max-width: 412px) 100vw, 412px\" \/><\/a>They come in wide variety of shapes and sizes. The most commons sizes are 3&#215;4\u00a0and\u00a04&#215;4 and you can get keypads with with words, letters and numbers written on the keys.<\/p>\n<p><strong>You can even <a href=\"https:\/\/randomnerdtutorials.com\/diy-3x4-keypad-for-the-arduino-includes-schematics\/\" target=\"_blank\" rel=\"noopener noreferrer\">create your own keypad<\/a>\u00a0from scratch.<\/strong><\/p>\n<p>If you follow this tutorial you can control any keypad.<\/p>\n<h3>Description<\/h3>\n<p>These keypads\u00a0very\u00a0popular among the Arduino tinkerers.\u00a0They\u00a0are very cheap and you can use them with\u00a0any microcontroller (MCU).<\/p>\n<h3>Where to buy?<\/h3>\n<p>You can purchase these modules for just a few dollars. <a href=\"https:\/\/makeradvisor.com\/tools\/membrane-keypad\/\" target=\"_blank\" rel=\"noopener noreferrer\">Click here<\/a>\u00a0to compare the <a href=\"https:\/\/makeradvisor.com\/tools\/membrane-keypad\/\" target=\"_blank\" rel=\"noopener noreferrer\">membrane keypad<\/a> on several stores and find the best price.<\/p>\n<p>You can use the preceding links or go directly to <a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\">MakerAdvisor.com\/tools<\/a> to find all the parts for your projects at the best price!<\/p><p style=\"text-align:center;\"><a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/header-200.png?w=1200&#038;quality=100&#038;strip=all&#038;ssl=1\"><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3>How it Works?<\/h3>\n<p>A membrane keypad is\u00a0a matrix consisting of rows and columns. Each key is assigned\u00a0to a certain row and column\u00a0(see the picture below).<\/p>\n<p>On a 12\u00a0button keypad you have\u00a04\u00a0rows and 3 columns. The first key\u00a0would make a link between Row 1 and Column 1 (R1C1). 2 would be R1C2, 3 R1C3, * \u00a0R4C1, 9 R3C3 and so on.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/07\/how-it-works-keypad.png?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"aligncenter wp-image-9211 \" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/07\/how-it-works-keypad.png?resize=594%2C367&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"how it works - keypad\" width=\"594\" height=\"367\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/07\/how-it-works-keypad.png?w=771&amp;quality=100&amp;strip=all&amp;ssl=1 771w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/07\/how-it-works-keypad.png?resize=300%2C185&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 594px) 100vw, 594px\" \/><\/a><\/p>\n<h3>Arduino with\u00a0Membrane Keypad<\/h3>\n<p>You need the following components to make this circuit:<\/p>\n<ul>\n<li>1x Arduino (<a href=\"http:\/\/ebay.to\/1EJbhZE\" target=\"_blank\" rel=\"noopener noreferrer\">eBay<\/a>)<\/li>\n<li>1x Keypad\u00a0(<a href=\"http:\/\/ebay.to\/1Ie0JEE\" target=\"_blank\" rel=\"noopener noreferrer\">eBay<\/a>)<\/li>\n<li>Jumper Wires<\/li>\n<\/ul>\n<h3>Schematics<\/h3>\n<p>Follow the next schematics. If your keypad is different from the one below, try to search for the datasheet online.<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"aligncenter wp-image-9206 size-full\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/07\/membrane-keyboard-arduin-tutorial-schematics.png?resize=550%2C273&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"membrane keyboard arduin tutorial schematics\" width=\"550\" height=\"273\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/07\/membrane-keyboard-arduin-tutorial-schematics.png?w=550&amp;quality=100&amp;strip=all&amp;ssl=1 550w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/07\/membrane-keyboard-arduin-tutorial-schematics.png?resize=300%2C149&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/p>\n<h3>Library Download<\/h3>\n<p>Here\u2019s the library\u00a0you need for this project:<\/p>\n<ol>\n<li>Download the <a href=\"http:\/\/playground.arduino.cc\/Code\/Keypad#Download\" target=\"_blank\" rel=\"noopener noreferrer\">Keypad\u00a0library<\/a><\/li>\n<li>Unzip the Keypad\u00a0library<\/li>\n<li>Install the Keypad\u00a0library in your Arduino IDE by moving the unzipped folder to: Arduino\\Libraries<\/li>\n<li>Restart your Arduino IDE<\/li>\n<\/ol>\n<h3>Uploading the Code<\/h3>\n<p>If your keypad doesn&#8217;t work with code below you might have to\u00a0change the connections from the previous\u00a0schematics.<\/p>\n<p>Search the web or go to the store that sold\u00a0you the keypad to\u00a0find the datasheet for your keypad.<\/p>\n<p><strong>Note:<\/strong> If your keypad has more keys you can change lines 3 and 4 to add the right number of rows and columns. Then in line 5 you can change the array to match your keypad keys.<\/p>\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">#include &quot;Keypad.h&quot;\n \nconst byte ROWS = 4; \/\/ number of rows\nconst byte COLS = 3; \/\/ number of columns\nchar keys[ROWS][COLS] = {\n{'1','2','3'},\n{'4','5','6'},\n{'7','8','9'},\n{'#','0','*'}\n};\n\nbyte rowPins[ROWS] = {8, 7, 6, 5}; \/\/ row pinouts of the keypad R1 = D8, R2 = D7, R3 = D6, R4 = D5\nbyte colPins[COLS] = {4, 3, 2};    \/\/ column pinouts of the keypad C1 = D4, C2 = D3, C3 = D2\nKeypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);\n \nvoid setup()\n{\n  Serial.begin(9600);\n}\n \nvoid loop()\n{\n  char key = keypad.getKey(); \n  if (key != NO_KEY)\n    Serial.println(key);\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/Arduino_with_Keypad.ino\" target=\"_blank\">View raw code<\/a><\/p>\n<h3>Demonstration<\/h3>\n<p>In this project when you press a key, it&#8217;s displayed the value in your serial montior.\u00a0Here\u2019s what you should see in your Arduino IDE serial monitor when you start pressing the keypad keys.<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-9213 size-full\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/07\/serial-monitor-with-arduino-and-keypad.jpg?resize=474%2C334&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"serial monitor with arduino and keypad\" width=\"474\" height=\"334\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/07\/serial-monitor-with-arduino-and-keypad.jpg?w=474&amp;quality=100&amp;strip=all&amp;ssl=1 474w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/07\/serial-monitor-with-arduino-and-keypad.jpg?resize=300%2C211&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><\/p>\n<h3>Conclusion<\/h3>\n<p>Now you can create an\u00a0interface for your Arduino using a keypad. You could also <a href=\"https:\/\/randomnerdtutorials.com\/arduino-display-the-led-brightness-on-a-lcd-16x2\/\" target=\"_blank\" rel=\"noopener noreferrer\">add an LCD to this project<\/a>.<\/p>\n<p>I hope you found this guide useful.<\/p>\n<p><strong>Share this post<\/strong> with a friend that also likes electronics!<\/p>\n<p>You can contact me by leaving a comment. If you like this post probably you might like my next ones, so please support me by <a href=\"https:\/\/randomnerdtutorials.com\/download\">subscribing my blog<\/a> and my Facebook Page.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A keypad allows you to interact with a\u00a0microcontroller. You can salvage\u00a0these keypads from old telephones or you can purchase\u00a0them from most\u00a0electronics store for less than $2.<\/p>\n","protected":false},"author":1,"featured_media":9206,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2,302,231,269,264,10],"tags":[],"class_list":["post-9202","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-0-guide","category-genuino","category-guide-project","category-project","category-a-tutorials"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/07\/membrane-keyboard-arduin-tutorial-schematics.png?fit=550%2C273&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/9202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=9202"}],"version-history":[{"count":0,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/9202\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/9206"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=9202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=9202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=9202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}