{"id":1288,"date":"2014-06-07T20:27:51","date_gmt":"2014-06-07T18:27:51","guid":{"rendered":"http:\/\/labalec.fr\/erwan\/?p=1288"},"modified":"2014-06-08T15:20:26","modified_gmt":"2014-06-08T13:20:26","slug":"arduino-use-a-shift-register-74hc595-and-a-darlington-array-uln2803","status":"publish","type":"post","link":"https:\/\/labalec.fr\/erwan\/?p=1288","title":{"rendered":"Arduino : use a shift register (74HC595) and a transistor array (ULN2803)"},"content":{"rendered":"<p>Still on my journey to a wordclock&#8230;<\/p>\n<p>In the previous <a href=\"https:\/\/labalec.fr\/erwan\/?p=1275\" target=\"_blank\">article<\/a>, we have seen how to use a shift register to control up to 8 digital outputs (or more if you cascade IC&rsquo;s).<\/p>\n<p>One drawback in the previous setup is that we had to use one transistor per digital output (to control a device powered by another source).<br \/>\nThat is 8 extra transistors, 8*3 extra wires, etc : not very practical and especially if we intend to control several shift registers IC&rsquo;s. (i plan on using 3 in my wordclock project)<\/p>\n<p>So this is where the <a href=\"http:\/\/www.ti.com\/lit\/ds\/symlink\/uln2803a.pdf\" target=\"_blank\">ULN2803 <\/a>comes in : 8 NPN transistors and one common ground in one integrated circuit.<\/p>\n<p><a href=\"https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2014\/06\/uln2803.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1292\" src=\"https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2014\/06\/uln2803-207x300.jpg\" alt=\"uln2803\" width=\"207\" height=\"300\" srcset=\"https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2014\/06\/uln2803-207x300.jpg 207w, https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2014\/06\/uln2803.jpg 285w\" sizes=\"auto, (max-width: 207px) 100vw, 207px\" \/><\/a><\/p>\n<p>See below a refreshed schema (compared to the previous article). Note that I have decided to power my IC&rsquo;s with my (regulated) Arduino 5v but I could as well have used my battery pack power.<br \/>\nOur 74HC595 will control our ULN2803 (by sending HIGH or LOW on the input) which in turn will drive the current thru each output\/led.<\/p>\n<p><a href=\"https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2014\/06\/uln2803a_bb.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1291 size-large\" src=\"https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2014\/06\/uln2803a_bb-1024x629.png\" alt=\"uln2803a_bb\" width=\"695\" height=\"426\" srcset=\"https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2014\/06\/uln2803a_bb-1024x629.png 1024w, https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2014\/06\/uln2803a_bb-300x184.png 300w\" sizes=\"auto, (max-width: 695px) 100vw, 695px\" \/><\/a><\/p>\n<p>the Arduino sketch :<\/p>\n<pre>\/\/the pins we are using\r\nint latchPin = 2;\r\nint clockPin = 3;\r\nint dataPin = 4;\r\n \r\nvoid setup() {\r\n  \/\/set all the pins used to talk to the chip\r\n  \/\/as output pins so we can write to them\r\n  pinMode(latchPin, OUTPUT);\r\n  pinMode(clockPin, OUTPUT);\r\n  pinMode(dataPin, OUTPUT);\r\n}\r\n \r\nvoid loop() {\r\n  for (int i = 0; i < 8; i++) {\r\n \r\n    \/\/take the latchPin low so the LEDs don't change while we are writing data\r\n    digitalWrite(latchPin, LOW);\r\n \r\n    \/\/shift out the bits\r\n    shiftOut(dataPin, clockPin, MSBFIRST, i);  \r\n \r\n    \/\/take the latch pin high so the pins reflect\r\n    \/\/the data we have sent\r\n    digitalWrite(latchPin, HIGH);\r\n\r\n    \/\/ pause before next value:\r\n    delay(1000);\r\n  }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Still on my journey to a wordclock&#8230; In the previous article, we have seen how to use a shift register to control up to 8 digital outputs (or more if you cascade IC&rsquo;s). One drawback in the previous setup is that we had to use one transistor per digital output (to control a device powered <a href='https:\/\/labalec.fr\/erwan\/?p=1288' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[51,50],"class_list":["post-1288","post","type-post","status-publish","format-standard","hentry","category-arduino","tag-74hc595","tag-uln2803","category-18-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"_links":{"self":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts\/1288","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1288"}],"version-history":[{"count":13,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts\/1288\/revisions"}],"predecessor-version":[{"id":1309,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts\/1288\/revisions\/1309"}],"wp:attachment":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}