{"id":1348,"date":"2014-07-06T19:39:48","date_gmt":"2014-07-06T17:39:48","guid":{"rendered":"http:\/\/labalec.fr\/erwan\/?p=1348"},"modified":"2014-09-28T16:13:38","modified_gmt":"2014-09-28T14:13:38","slug":"cascade-two-74hc595","status":"publish","type":"post","link":"https:\/\/labalec.fr\/erwan\/?p=1348","title":{"rendered":"Arduino : Cascade two 74HC595"},"content":{"rendered":"<p>In a <a href=\"https:\/\/labalec.fr\/erwan\/?p=1310\" target=\"_blank\">previous article<\/a>, we had used a\u00a074HC595\u00a0to control a\u00a0ULN2803.<br \/>\nThis enabled us to deal with 8 LED&rsquo;s.<\/p>\n<p>Lets now cascade two 74HC595\u00a0to deal with 16 LED&rsquo;s.<br \/>\nTo do this, we will use the serial output of 74HC595\u00a0#1 to the serial input of 74HC595\u00a0#2.<\/p>\n<p>Here below the schema.<\/p>\n<p><a href=\"https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2014\/07\/uln2803a_4_bb.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1349\" src=\"https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2014\/07\/uln2803a_4_bb-1024x725.png\" alt=\"uln2803a_4_bb\" width=\"695\" height=\"492\" srcset=\"https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2014\/07\/uln2803a_4_bb-1024x725.png 1024w, https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2014\/07\/uln2803a_4_bb-300x212.png 300w\" sizes=\"auto, (max-width: 695px) 100vw, 695px\" \/><\/a><\/p>\n<p>Here below the arduino sketch.<br \/>\nNote that we use two arrays, and that we go up and down in each array.<\/p>\n<pre>\r\n\/\/the pins we are using\r\nint latchPin = 2;\r\nint clockPin = 3;\r\nint dataPin = 4;\r\n\r\n\r\nbyte dataArrayA[9];\r\nbyte dataArrayB[9];\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  dataArrayA[0] = 0xFF; \/\/11111111\r\n  dataArrayA[1] = 0xFE; \/\/11111110\r\n  dataArrayA[2] = 0xFC; \/\/11111100\r\n  dataArrayA[3] = 0xF8; \/\/11111000\r\n  dataArrayA[4] = 0xF0; \/\/11110000\r\n  dataArrayA[5] = 0xE0; \/\/11100000\r\n  dataArrayA[6] = 0xC0; \/\/11000000\r\n  dataArrayA[7] = 0x80; \/\/10000000\r\n  dataArrayA[8] = 0x00; \/\/00000000\r\n  \r\n  dataArrayB[8] = 0xFF; \/\/11111111\r\n  dataArrayB[7] = 0xFE; \/\/11111110\r\n  dataArrayB[6] = 0xFC; \/\/11111100\r\n  dataArrayB[5] = 0xF8; \/\/11111000\r\n  dataArrayB[4] = 0xF0; \/\/11110000\r\n  dataArrayB[3] = 0xE0; \/\/11100000\r\n  dataArrayB[2] = 0xC0; \/\/11000000\r\n  dataArrayB[1] = 0x80; \/\/10000000\r\n  dataArrayB[0] = 0x00; \/\/00000000\r\n\r\n}\r\n \r\nvoid loop() {\r\n  for (int i = 0; i < 9; i++) {\r\n    digitalWrite(latchPin, LOW);\r\n    shiftOut(dataPin, clockPin, MSBFIRST, dataArrayA[i]);  \r\n    shiftOut(dataPin, clockPin, MSBFIRST, dataArrayB[i]);\r\n    digitalWrite(latchPin, HIGH);\r\n    delay(100);\r\n  }\r\n\r\n  for (int i = 8; i >= 0; i--) {\r\n  digitalWrite(latchPin, LOW);\r\n  shiftOut(dataPin, clockPin, MSBFIRST, dataArrayA[i]);\r\n  shiftOut(dataPin, clockPin, MSBFIRST, dataArrayB[i]);  \r\n  digitalWrite(latchPin, HIGH);\r\n  delay(100);\r\n  }\r\n  \r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In a previous article, we had used a\u00a074HC595\u00a0to control a\u00a0ULN2803. This enabled us to deal with 8 LED&rsquo;s. Lets now cascade two 74HC595\u00a0to deal with 16 LED&rsquo;s. To do this, we will use the serial output of 74HC595\u00a0#1 to the serial input of 74HC595\u00a0#2. Here below the schema. Here below the arduino sketch. Note that <a href='https:\/\/labalec.fr\/erwan\/?p=1348' 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":[],"class_list":["post-1348","post","type-post","status-publish","format-standard","hentry","category-arduino","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\/1348","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=1348"}],"version-history":[{"count":6,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts\/1348\/revisions"}],"predecessor-version":[{"id":1478,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts\/1348\/revisions\/1478"}],"wp:attachment":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}