{"id":682,"date":"2007-06-29T22:39:07","date_gmt":"2007-06-29T21:39:07","guid":{"rendered":"http:\/\/EvertDekker.com\/?p=682"},"modified":"2023-01-07T16:01:43","modified_gmt":"2023-01-07T15:01:43","slug":"1wire-keypad","status":"publish","type":"post","link":"https:\/\/evertdekker.com\/wp\/?p=682","title":{"rendered":"1Wire Keypad"},"content":{"rendered":"<hr \/>\n<p>Before there where touch-panels etc. to control my <a href=\"http:\/\/www.evertdekker.com\/wp\/?cat=18\">Joshua domotica<\/a> I designed an 1-wire keypad with 16 buttons.<br \/>\nAs the title suggest it uses only 1wire to communicate with the micro controller instead of 8 pins for a 4&#215;4 matrix.<br \/>\nQuickly after I build this it was replaced with an<a href=\"http:\/\/evertdekker.com\/?p=438\"> 5&#8243; touchscreen<\/a>. Key pads are not that flexible if you often add devices to the Joshua bus.<br \/>\nThe hart of the electronics is the Dallas (Now these days Maxim) 1-wire DS2408 8-channel addressable switch.<br \/>\nThe concept of the keypad is same as most of the keypads, keys are arranged in a 4&#215;4 matrix.<br \/>\nAlso the reading of the keypad is the same as most of the matrix keypads.<br \/>\nYou make 1 column at the time high and scan the rows to see if one of the inputs becomes high. From this combination of row &amp; column you can determine what key is pressed.<\/p>\n<p>Design is simple one layer pcb, home made. The switches are cheap tact switches. They are behind a Coreldraw design front panel that&#8217;s printed on front panel folie and sealed with transparent protective folie. To make it easier to press the button you need to drill the holes in the aluminum plate bigger the then the tact switches, 10mm is enough.<br \/>\nIf you need to press to hard to activate the tact switch you can add some tape or leftover front panel folie between the front panel folie and the tact switch.<\/p>\n<div class=\"n2_ss_slider_publish__option_code\" dir=\"ltr\" data-mode=\"id\"><\/div>\n<p>Update 29-04-2016:<br \/>\nThere&#8217;s no schematic anymore because the used cad program won&#8217;t run under windows 8, but with the help of the source code it&#8217;s easy to redraw.<\/p>\n<p>Here&#8217;s the code to control the DS2408 with Bascom.<\/p>\n<pre class=\"brush: actionscript3; gutter: true\">&#039;==========================================\r\n&#039; 1 Wire Keypad with ds2408 ver 1.0\r\n&#039;==========================================\r\n\r\nReadkeypad:\r\n Row(1) = &amp;B01111111                                        &#039;Define rows,\r\n Row(2) = &amp;B10111111                                        &#039;Looks strange, but needed for\r\n Row(3) = &amp;B11011111                                        &#039;for simple pcb design\r\n Row(4) = &amp;B11111110\r\n\r\n For Rowlus = 1 To 4                                        &#039;4 rows to scan\r\n Gosub Setupds2408                                          &#039;setup the pio\r\n 1wreset                                                    &#039;reset 1 wire\r\n Ar(1) = &amp;HCC                                               &#039;Skip read rom command\r\n Ar(2) = &amp;H5A                                               &#039;channel access write\r\n Ar(3) = Row(rowlus)                                        &#039;scan row\r\n Ar(4) = &amp;HFF - Ar(3)                                       &#039;inverted byte\r\n 1wwrite Ar(1) , 4                                          &#039;write 4 bytes to ds2408\r\n Ar(1) = 1wread(2)                                          &#039;read 2 bytes, ar(1) is &quot;verification&quot; but not used in this sample\r\n A = Ar(2) And &amp;B00011110                                   &#039;Mask ar(2) byte for columns\r\n  Select Case A\r\n  Case 30 : Key = 0                                         &#039;no key pressed\r\n  Case 28 : If Rowlus = 1 Then Key = 2                      &#039;key pressed on column 1\r\n            If Rowlus = 2 Then Key = 3                      &#039;easy assign a value to a key\r\n            If Rowlus = 3 Then Key = 4                      &#039;in this sample we use keys 1-16\r\n            If Rowlus = 4 Then Key = 1\r\n  Case 26 : If Rowlus = 1 Then Key = 6                      &#039;key pressed on column 2\r\n            If Rowlus = 2 Then Key = 7\r\n            If Rowlus = 3 Then Key = 8\r\n            If Rowlus = 4 Then Key = 5\r\n  Case 22 : If Rowlus = 1 Then Key = 14                     &#039;key pressed on column 4\r\n            If Rowlus = 2 Then Key = 15\r\n            If Rowlus = 3 Then Key = 16\r\n            If Rowlus = 4 Then Key = 13\r\n  Case 14 : If Rowlus = 1 Then Key = 10                     &#039;key pressed on column 3\r\n            If Rowlus = 2 Then Key = 11\r\n            If Rowlus = 3 Then Key = 12\r\n            If Rowlus = 4 Then Key = 9\r\n  Case Else : Key = 0                                       &#039;occurs when more then 1 key pressed\r\n End Select\r\n If Key &gt; 0 Then Exit For\r\n Next Rowlus\r\nReturn\r\n\r\nSetupds2408:\r\n1wreset\r\n Ar(1) = &amp;HCC                                               &#039;skip read rom\r\n Ar(2) = &amp;H5A                                               &#039;channel access write\r\n Ar(3) = &amp;B00011110                                         &#039;setup pio\r\n Ar(4) = &amp;HFF - Ar(3)                                       &#039;inverted byte\r\n 1wwrite Ar(1) , 4                                          &#039;write 4 bytes ds2408\r\n Ar(1) = 1wread(2)\r\nReturn<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Before there where touch-panels etc. to control my Joshua domotica I designed an 1-wire keypad with 16 buttons. As the title suggest it uses only 1wire to communicate with the micro controller instead of 8 pins for a 4&#215;4 matrix. Quickly after I build this it was replaced with an 5&#8243; touchscreen. Key pads are [&#8230;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[117,26,56,116],"class_list":["post-682","post","type-post","status-publish","format-standard","hentry","category-joshua","tag-1wire","tag-bascom","tag-domotica","tag-ds2408"],"_links":{"self":[{"href":"https:\/\/evertdekker.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/682","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/evertdekker.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/evertdekker.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/evertdekker.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/evertdekker.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=682"}],"version-history":[{"count":7,"href":"https:\/\/evertdekker.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/682\/revisions"}],"predecessor-version":[{"id":1862,"href":"https:\/\/evertdekker.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/682\/revisions\/1862"}],"wp:attachment":[{"href":"https:\/\/evertdekker.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=682"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/evertdekker.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=682"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/evertdekker.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=682"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}