{"id":22049,"date":"2017-12-30T09:23:45","date_gmt":"2017-12-30T02:23:45","guid":{"rendered":"http:\/\/tom.ji42.com\/?p=22049"},"modified":"2020-11-09T07:29:37","modified_gmt":"2020-11-09T00:29:37","slug":"arduino-keypad-i2c-interface-library","status":"publish","type":"post","link":"https:\/\/tom.tomwork.net\/?p=22049","title":{"rendered":"Arduino Keypad I2C interface library"},"content":{"rendered":"<p>MM74C922N datasheet at\u00a0http:\/\/www.ti.com\/lit\/ds\/symlink\/mm54c923.pdf<br \/>\nPCF8574 datasheet at\u00a0<a href=\"http:\/\/www.nxp.com\/documents\/data_sheet\/PCF8574.pdf\" rel=\"nofollow\">http:\/\/www.nxp.com\/documents\/data_sheet\/PCF8574.pdf<\/a><\/p>\n<p>Use this library freely.<\/p>\n<p><a href=\"https:\/\/raw.githubusercontent.com\/F4GOJ\/Keypad_I2C\/master\/images\/keypad_i2c_sch.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/F4GOJ\/Keypad_I2C\/master\/images\/keypad_i2c_sch.png\" alt=\"keypad_i2c\" \/><\/a><\/p>\n<p><!--more--><\/p>\n<h2><a id=\"user-content-hardware-connections\" class=\"anchor\" href=\"https:\/\/github.com\/F4GOJ\/Keypad_I2C#hardware-connections\" aria-hidden=\"true\"><\/a>Hardware connections<\/h2>\n<p>#####Keypad to Arduino :<\/p>\n<ul>\n<li>J1-1 -&gt; D2 or D3<\/li>\n<li>J1-2 -&gt; +5V<\/li>\n<li>J1-3 -&gt; A4<\/li>\n<li>J1-4 -&gt; A5<\/li>\n<li>J1-5 -&gt; Ground<\/li>\n<\/ul>\n<p>#####Expansion I2C port :<\/p>\n<ul>\n<li>J2-1 -&gt; Ground<\/li>\n<li>J2-2 -&gt; SCL<\/li>\n<li>J2-3 -&gt; SDA<\/li>\n<li>J2-4 -&gt; +5V<\/li>\n<\/ul>\n<h2><a id=\"user-content-installation\" class=\"anchor\" href=\"https:\/\/github.com\/F4GOJ\/Keypad_I2C#installation\" aria-hidden=\"true\"><\/a>Installation<\/h2>\n<p>To use the\u00a0<strong>Keypad_I2C<\/strong>\u00a0library:<\/p>\n<ul>\n<li>Go to\u00a0<a href=\"https:\/\/github.com\/F4GOJ\/Keypad_I2C\">https:\/\/github.com\/F4GOJ\/Keypad_I2C<\/a>, click the\u00a0<a href=\"https:\/\/github.com\/F4GOJ\/Keypad_I2C\/archive\/master.zip\">Download ZIP<\/a>\u00a0button and save the ZIP file to a convenient location on your PC.<\/li>\n<li>Uncompress the downloaded file. This will result in a folder containing all the files for the library, that has a name that includes the branch name, usually\u00a0<strong>Keypad_I2C-master<\/strong>.<\/li>\n<li>Rename the folder to\u00a0<strong>Keypad_I2C<\/strong>.<\/li>\n<li>Copy the renamed folder to the Arduino sketchbook\\libraries folder.<\/li>\n<\/ul>\n<h2><a id=\"user-content-usage-notes\" class=\"anchor\" href=\"https:\/\/github.com\/F4GOJ\/Keypad_I2C#usage-notes\" aria-hidden=\"true\"><\/a>Usage notes<\/h2>\n<p>You have to instantiate a\u00a0<strong>my_keypad_name<\/strong>\u00a0object.<\/p>\n<p>Keypad_I2C my_keypad_name(int i2c_addr, int int_pin);<\/p>\n<p>#####Parameters\u00a0<strong>i2c_addr :<\/strong>\u00a0I2C address of the interface\u00a0<em>(int)<\/em><br \/>\n<strong>int_pin :<\/strong>\u00a0Input pin 2 or 3 to attach the interrupt\u00a0<em>(int)<\/em><\/p>\n<div class=\"highlight highlight-source-c++\">\n<pre>#<span class=\"pl-k\">include<\/span> <span class=\"pl-s\"><span class=\"pl-pds\">&lt;<\/span>Keypad_I2c.h<span class=\"pl-pds\">&gt;<\/span><\/span>    <span class=\"pl-c\">\/\/http:\/\/github.com\/F4GOJ\/Keypad_I2C<\/span>\r\n\r\nKeypad_I2C <span class=\"pl-en\">KPD<\/span>(<span class=\"pl-c1\">0x26<\/span>, <span class=\"pl-c1\">2<\/span>);<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h2><a id=\"user-content-functions-\" class=\"anchor\" href=\"https:\/\/github.com\/F4GOJ\/Keypad_I2C#functions-\" aria-hidden=\"true\"><\/a>Functions :<\/h2>\n<p>###begin() #####Description Initialize and attach interrupt to the input pin, begins the wire connection. #####Syntax<code>KPD.begin();<\/code>\u00a0#####Parameters None. #####Returns None. #####Example<\/p>\n<div class=\"highlight highlight-source-c++\">\n<pre><span class=\"pl-k\">void<\/span> <span class=\"pl-en\">setup<\/span>(){\r\n KPD.<span class=\"pl-c1\">begin<\/span>();\r\n}<\/pre>\n<\/div>\n<p>###getKey() #####Description Get key pressed. #####Syntax\u00a0<code>KPD.getKey();<\/code>\u00a0#####Parameters None. #####Returns The code of the key pressed or 0 if no new key has been pressed.\u00a0<em>(char)<\/em>\u00a0#####Example<\/p>\n<div class=\"highlight highlight-source-c++\">\n<pre>ch = KPD.getKey();\r\n<span class=\"pl-k\">if<\/span>(ch != <span class=\"pl-c1\">0<\/span>){\r\n Serial.<span class=\"pl-c1\">print<\/span>(ch);\r\n}<\/pre>\n<\/div>\n<p>###getKeyNum() #####Description Get only numerical key pressed. #####Syntax\u00a0<code>KPD.getKeyNum();<\/code>\u00a0#####Parameters None. #####Returns The code of the numerical key pressed or 0 if no new key has been pressed.\u00a0<em>(char)<\/em>\u00a0#####Example<\/p>\n<div class=\"highlight highlight-source-c++\">\n<pre>ch = KPD.getKeyNum();\r\n<span class=\"pl-k\">if<\/span>(ch != <span class=\"pl-c1\">0<\/span>){\r\n Serial.<span class=\"pl-c1\">print<\/span>(ch);\r\n}<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>MM74C922N datasheet at\u00a0http:\/\/www.ti.com\/lit\/ds\/symlink\/mm54c923.pdf PCF8574 datasheet at\u00a0http:\/\/www.nxp.com\/documents\/data_sheet\/PCF8574.pdf Use this library freely.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","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":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[13],"tags":[],"class_list":["post-22049","post","type-post","status-publish","format-standard","hentry","category-13"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6cOVM-5JD","_links":{"self":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts\/22049","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=22049"}],"version-history":[{"count":2,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts\/22049\/revisions"}],"predecessor-version":[{"id":25361,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts\/22049\/revisions\/25361"}],"wp:attachment":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=22049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=22049"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=22049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}