{"id":730,"date":"2011-05-21T10:09:42","date_gmt":"2011-05-21T15:09:42","guid":{"rendered":"http:\/\/nootropicdesign.com\/projectlab\/?p=730"},"modified":"2018-11-02T09:06:23","modified_gmt":"2018-11-02T14:06:23","slug":"multiple-digit-shields","status":"publish","type":"post","link":"https:\/\/nootropicdesign.com\/projectlab\/2011\/05\/21\/multiple-digit-shields\/","title":{"rendered":"Driving Multiple Digit Shields from One Arduino"},"content":{"rendered":"<p><strong><em>Difficulty Level = 2<\/em><\/strong>  <a href=\"\/projectlab\/difficulty-levels\/\">[What&#8217;s this?]<\/a><\/p>\n<p>The <a href=\"https:\/\/nootropicdesign.com\/digitshield\/\" target=\"_blank\">Digit Shield<\/a> is a very easy-to-use Arduino shield that provides a digital readout for your Arduino projects.  <a href=\"https:\/\/nootropicdesign.com\/digitshield\/projects.html\" target=\"_blank\">Some example projects are here<\/a>.  <\/p>\n<p>One of my customers asked me about driving multiple Digit Shields from one Arduino.  I had never thought of that, but the customer had the idea of using a single Arduino to display the X,Y,Z positions of a CNC router.  I thought this was an intriguing idea, and with a little bit of experimentation and modification to the Digit Shield library, I was able to very easily accomplish this.<br \/>\n<div id=\"attachment_741\" style=\"width: 650px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2011\/05\/multiShield.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-741\" src=\"https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2011\/05\/multiShield-sm.jpg\" alt=\"\" title=\"multiShield-sm\" width=\"640\" height=\"480\" class=\"size-full wp-image-741\" srcset=\"https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2011\/05\/multiShield-sm.jpg 640w, https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2011\/05\/multiShield-sm-300x225.jpg 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><p id=\"caption-attachment-741\" class=\"wp-caption-text\">Driving multiple Digit Shields with one Arduino<\/p><\/div><br \/>\n&nbsp;<\/p>\n<p\/>\nWhen a Digit Shield is on top of an Arduino, the pins used to control the shield are 2, 3, 4, and 5.  In the picture above, this shield is displaying value &#8220;60.08&#8221;.  If we connect another shield, we obviously have to use different Arduino pins to drive it.  The second shield in the picture above (the one displaying &#8220;59&#8221;) is connected to Arduino pins 6, 7, 8, and 9.  Of course, the wires still connect to pins 2, 3, 4, and 5 on the shield itself.<\/p>\n<p>The 3rd shield in the picture displaying &#8220;1800&#8221; has its pins 2, 3, 4, and 5 connected to Arduino pins A3, A2, A1, and A0 respectively.  In the code, analog pins are used as digital pins by referring to them as 17, 16, 15, and 14.<\/p>\n<p>What about the code?  I added a constructor for <span class=\"code\">DigitShieldClass<\/span> to the library so you can create new objects to represent the additional shields.  The shield on the Arduino is still referenced as &#8220;DigitShield&#8221;, but the additional ones are referenced as &#8220;digitShield2&#8221; and &#8220;digitShield3&#8221;.  Here&#8217;s how the shields are declared and initialized.  <\/p>\n<pre class=\"codeblock\">\r\n\/\/ Create a second Digit Shield connected to Arduino pins 6,7,8,9                            \r\n\/\/ Connected to pins 2,3,4,5 on the shield, respectively.                                    \r\nDigitShieldClass digitShield2(6, 7, 8, 9);\r\n\r\n\/\/ Create a third Digit Shield connected to Arduino pins 17,16,15,14 (A3,A2,A1,A0)           \r\n\/\/ Connected to pins 2,3,4,5 on the shield, respectively.                                    \r\nDigitShieldClass digitShield3(17, 16, 15, 14);\r\n\r\nvoid setup() {\r\n  \/\/ The static variable DigitShield refers to the default                                   \r\n  \/\/ Digit Shield that is directly on top of the Arduino                                     \r\n  DigitShield.begin();\r\n  DigitShield.setPrecision(2);\r\n\r\n  \/\/ Initialize the other two shields                                                        \r\n  digitShield2.begin();\r\n  digitShield3.begin();\r\n\r\n  \/\/ set all values to 0\r\n  DigitShield.setValue(0);\r\n  digitShield2.setValue(0);\r\n  digitShield3.setValue(0);\r\n}\r\n<\/pre>\n<p>The full code example is called &#8220;MultiShieldExample&#8221; and is included in the <a href=\"https:\/\/nootropicdesign.com\/digitshield\/downloads\/DigitShieldLibrary.zip\">Digit Shield library<\/a>.<\/p>\n<p>Also note that I&#8217;m providing power to the off-Arduino shields with a 7805 voltage regulator.  The Arduino&#8217;s voltage regulator can deliver quite a bit of power, but it got rather warm when driving all these LEDs.  So, in the picture above, there&#8217;s a 7805 which provides 5V to the 5V pins on the off-Arduino shields.  Also make sure you connect all the grounds together.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Difficulty Level = 2 [What&#8217;s this?] The Digit Shield is a very easy-to-use Arduino shield that provides a digital readout for your Arduino projects. Some example projects are here. One of my customers asked me about driving multiple Digit Shields from one Arduino. I had never thought of that, but the customer had the idea [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[3],"tags":[],"class_list":["post-730","post","type-post","status-publish","format-standard","hentry","category-arduino"],"_links":{"self":[{"href":"https:\/\/nootropicdesign.com\/projectlab\/wp-json\/wp\/v2\/posts\/730","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nootropicdesign.com\/projectlab\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nootropicdesign.com\/projectlab\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nootropicdesign.com\/projectlab\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nootropicdesign.com\/projectlab\/wp-json\/wp\/v2\/comments?post=730"}],"version-history":[{"count":13,"href":"https:\/\/nootropicdesign.com\/projectlab\/wp-json\/wp\/v2\/posts\/730\/revisions"}],"predecessor-version":[{"id":1951,"href":"https:\/\/nootropicdesign.com\/projectlab\/wp-json\/wp\/v2\/posts\/730\/revisions\/1951"}],"wp:attachment":[{"href":"https:\/\/nootropicdesign.com\/projectlab\/wp-json\/wp\/v2\/media?parent=730"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nootropicdesign.com\/projectlab\/wp-json\/wp\/v2\/categories?post=730"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nootropicdesign.com\/projectlab\/wp-json\/wp\/v2\/tags?post=730"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}