{"id":2884,"date":"2013-10-23T04:00:24","date_gmt":"2013-10-22T19:00:24","guid":{"rendered":"https:\/\/blog.eldhrimnir.com?p=2884"},"modified":"2013-10-23T15:43:35","modified_gmt":"2013-10-23T06:43:35","slug":"arduino%e3%81%a7tlc594074138%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9fled%e5%88%b6%e5%be%a1","status":"publish","type":"post","link":"https:\/\/blog.eldhrimnir.com\/?p=2884","title":{"rendered":"arduino\u3067TLC5940+74138\u3092\u4f7f\u3063\u305fLED\u5236\u5fa1"},"content":{"rendered":"<p>\u30c6\u30b9\u30c8\u7528\u306b\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002TLC\u5358\u4f53\u3067\u306f16\u500b\u8fc4\u306eLED\u3092\u5236\u5fa1\u51fa\u6765\u307e\u3059\u304c\u300174138\u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u3042\u3052\u308b\u3053\u3068\u3067x8\u306e128\u500b\u306eLED\u304c\u5236\u5fa1\u51fa\u6765\u307e\u3059\u30028\u500d\u3067\u3059\u3001TLC\u306a\u3089\u30708\u500b\u7e4b\u3044\u3066\u540c\u3058\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u304b\u3001\u30b3\u30b9\u30c8\u304c\u2026\u3002<\/p>\n<p>\u25a0\u57fa\u677f\u30a4\u30e1\u30fc\u30b8<\/p>\n<p><a href=\"https:\/\/blog.eldhrimnir.comwp-content\/uploads\/2013\/08\/74138_2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-3095\" alt=\"74138_2\" src=\"https:\/\/blog.eldhrimnir.comwp-content\/uploads\/2013\/08\/74138_2.png\" width=\"646\" height=\"487\" srcset=\"https:\/\/blog.eldhrimnir.com\/wp-content\/uploads\/2013\/08\/74138_2.png 808w, https:\/\/blog.eldhrimnir.com\/wp-content\/uploads\/2013\/08\/74138_2-300x226.png 300w\" sizes=\"(max-width: 646px) 100vw, 646px\" \/><\/a><\/p>\n<p>\u25a0\u56de\u8def\u56f3(\u629c\u304d\u51fa\u3057)<\/p>\n<p><a href=\"https:\/\/blog.eldhrimnir.comwp-content\/uploads\/2013\/08\/741382.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3094\" alt=\"74138\" src=\"https:\/\/blog.eldhrimnir.comwp-content\/uploads\/2013\/08\/741382.png\" width=\"640\" height=\"400\" srcset=\"https:\/\/blog.eldhrimnir.com\/wp-content\/uploads\/2013\/08\/741382.png 640w, https:\/\/blog.eldhrimnir.com\/wp-content\/uploads\/2013\/08\/741382-300x187.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p><!--more--><\/p>\n<p>\u25a0\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/p>\n<p>[cpp]<\/p>\n<p>#include &quot;Tlc5940.h&quot;<\/p>\n<p>\/\/74HC138 LED control pins<br \/>\nconst int PIN_LED_CTR_3 = 7;<br \/>\nconst int PIN_LED_CTR_2 = 6;<br \/>\nconst int PIN_LED_CTR_1 = 5;<\/p>\n<p>void setup()<br \/>\n{<br \/>\n\/* Call Tlc.init() to setup the tlc.<br \/>\nYou can optionally pass an initial PWM value (0 &#8211; 4095) for all channels.*\/<br \/>\nTlc.init();<\/p>\n<p>pinMode(PIN_LED_CTR_1, OUTPUT);<br \/>\npinMode(PIN_LED_CTR_2, OUTPUT);<br \/>\npinMode(PIN_LED_CTR_3, OUTPUT);<\/p>\n<p>}<br \/>\nvoid lightLED(int idx) {<br \/>\ndigitalWrite(PIN_LED_CTR_3, (idx &gt;&gt; 2) &amp; 0x1);<br \/>\ndigitalWrite(PIN_LED_CTR_2, (idx &gt;&gt; 1) &amp; 0x1);<br \/>\ndigitalWrite(PIN_LED_CTR_1, idx &amp; 0x1);<br \/>\n}<\/p>\n<p>void loop()<br \/>\n{<br \/>\nint direction = 1;<br \/>\nfor (int channel = 0; channel &lt; NUM_TLCS * 16; channel += direction) {<\/p>\n<p>Tlc.clear();<\/p>\n<p>if (channel == 0) {<br \/>\ndirection = 1;<br \/>\n} else {<br \/>\nTlc.set(channel &#8211; 1, 1000);<br \/>\n}<br \/>\nTlc.set(channel, 4095);<br \/>\nif (channel != NUM_TLCS * 16 &#8211; 1) {<br \/>\nTlc.set(channel + 1, 1000);<br \/>\n} else {<br \/>\ndirection = -1;<br \/>\n}<\/p>\n<p>Tlc.update();<br \/>\nfor (int i=0; i &lt;= 8; i++){<br \/>\nfor (int j=0; j &lt;= 7; j++){<br \/>\nlightLED(j);<br \/>\ndelay(1);<br \/>\n}<br \/>\ndelay(1);<br \/>\n}<br \/>\n}<br \/>\n}<\/p>\n<p>[\/cpp]<\/p>\n<p>\u30e1\u30ea\u30c3\u30c8\u3068\u3057\u3066\u99c6\u52d5\u7528\u306eFET\u304c\u5916\u4ed8\u3051\u306a\u306e\u3067\u6bd4\u8f03\u7684\u5927\u96fb\u6d41\u3092\u6d41\u305b\u307e\u3059\u3002TLC\u306e\u30b7\u30f3\u30af\u96fb\u6d41\u5236\u9650\u3092\u5916\u305d\u3046\u3068\u3059\u308b\u30688ch\u30a4\u30f3\u30d0\u30fc\u30bf\u30fc\u3068N-FET\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3051\u308c\u3069\u3082\u5909\u66f4\u306f\u7c21\u5358\u3067\u3059\u3002\u90e8\u54c1\u70b9\u6570\u304c\u591a\u304f\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u304c\u6b20\u70b9\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>74138\u306f\u5165\u529b\u30dd\u30fc\u30c8\u72b6\u614b\u306e\u5909\u5316\u3067\u5373\u51fa\u529b\u30dd\u30fc\u30c8\u304c\u5909\u5316\u3059\u308b\u306e\u304c\u7c21\u5358\u3067\u3044\u3044\u3067\u3059\u306d\u3002<\/p>\n<p><a href=\"https:\/\/blog.eldhrimnir.comwp-content\/uploads\/2013\/08\/IMG_6152res.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-3102\" alt=\"IMG_6152res\" src=\"https:\/\/blog.eldhrimnir.comwp-content\/uploads\/2013\/08\/IMG_6152res-1024x768.jpg\" width=\"430\" height=\"323\" srcset=\"https:\/\/blog.eldhrimnir.com\/wp-content\/uploads\/2013\/08\/IMG_6152res-1024x768.jpg 1024w, https:\/\/blog.eldhrimnir.com\/wp-content\/uploads\/2013\/08\/IMG_6152res-300x225.jpg 300w, https:\/\/blog.eldhrimnir.com\/wp-content\/uploads\/2013\/08\/IMG_6152res.jpg 1408w\" sizes=\"(max-width: 430px) 100vw, 430px\" \/><\/a><\/p>\n<p>\u6b21\u56de\u306f\u3001TLC+74595\u3092\u5236\u5fa1\u3057\u3066\u307f\u305f\u3044\u3068\u304a\u3082\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30c6\u30b9\u30c8\u7528\u306b\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002TLC\u5358\u4f53\u3067\u306f16\u500b\u8fc4\u306eLED\u3092\u5236\u5fa1\u51fa\u6765\u307e\u3059\u304c\u300174138\u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u3042\u3052\u308b\u3053\u3068\u3067x8\u306e128\u500b\u306eLED\u304c\u5236\u5fa1\u51fa\u6765\u307e\u3059\u30028\u500d\u3067\u3059\u3001TLC\u306a\u3089\u30708\u500b\u7e4b\u3044\u3066\u540c\u3058\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u304b\u3001\u30b3\u30b9\u30c8\u304c\u2026\u3002 \u25a0\u57fa [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,16],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.eldhrimnir.com\/index.php?rest_route=\/wp\/v2\/posts\/2884"}],"collection":[{"href":"https:\/\/blog.eldhrimnir.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.eldhrimnir.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.eldhrimnir.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.eldhrimnir.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2884"}],"version-history":[{"count":0,"href":"https:\/\/blog.eldhrimnir.com\/index.php?rest_route=\/wp\/v2\/posts\/2884\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.eldhrimnir.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.eldhrimnir.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2884"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.eldhrimnir.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}