{"id":1012,"date":"2016-01-26T13:52:42","date_gmt":"2016-01-26T12:52:42","guid":{"rendered":"https:\/\/www.puhy.cz\/blog\/?p=1012"},"modified":"2018-08-24T10:03:38","modified_gmt":"2018-08-24T09:03:38","slug":"tuning-detskeho-auticka-s-arduinem-a-hrsti-ledek-knight-rider","status":"publish","type":"post","link":"https:\/\/www.puhy.cz\/blog\/tuning-detskeho-auticka-s-arduinem-a-hrsti-ledek-knight-rider\/","title":{"rendered":"Tuning d\u011btsk\u00e9ho aut\u00ed\u010dka s Arduinem a hrst\u00ed LEDek (Knight &#8211; rider)"},"content":{"rendered":"<p>D\u00edky\u00a0p\u00e1r LED diod\u00e1m a Arduinu m\u016f\u017eete o\u017eivit d\u011btem nudn\u00e9 aut\u00ed\u010dko o skv\u011bl\u00e9 sv\u011bteln\u00e9 efekty. Konkr\u00e9tn\u00ed n\u00e1vod na efektn\u00ed b\u011b\u017e\u00edc\u00ed sv\u011btlo, jako v legend\u00e1rn\u00edm Knight Rideru, naleznete v tomto \u010dl\u00e1nku.<\/p>\n<h2>Hardware<\/h2>\n\n\t\t<style type=\"text\/css\">\n\t\t\t#gallery-1 {\n\t\t\t\tmargin: auto;\n\t\t\t}\n\t\t\t#gallery-1 .gallery-item {\n\t\t\t\tfloat: left;\n\t\t\t\tmargin-top: 10px;\n\t\t\t\ttext-align: center;\n\t\t\t\twidth: 33%;\n\t\t\t}\n\t\t\t#gallery-1 img {\n\t\t\t\tborder: 2px solid #cfcfcf;\n\t\t\t}\n\t\t\t#gallery-1 .gallery-caption {\n\t\t\t\tmargin-left: 0;\n\t\t\t}\n\t\t\t\/* see gallery_shortcode() in wp-includes\/media.php *\/\n\t\t<\/style>\n\t\t<div id='gallery-1' class='gallery galleryid-1012 gallery-columns-3 gallery-size-thumbnail'><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/www.puhy.cz\/blog\/tuning-detskeho-auticka-s-arduinem-a-hrsti-ledek-knight-rider\/p1170227\/'><img width=\"150\" height=\"150\" src=\"https:\/\/www.puhy.cz\/wprsblg1\/wp-content\/uploads\/2016\/01\/P1170227-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/a>\n\t\t\t<\/dt><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/www.puhy.cz\/blog\/tuning-detskeho-auticka-s-arduinem-a-hrsti-ledek-knight-rider\/p1170225\/'><img width=\"150\" height=\"150\" src=\"https:\/\/www.puhy.cz\/wprsblg1\/wp-content\/uploads\/2016\/01\/P1170225-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/a>\n\t\t\t<\/dt><\/dl>\n\t\t\t<br style='clear: both' \/>\n\t\t<\/div>\n\n<p>8 \u010derven\u00fdch LED diod jsem p\u0159ipojil na porty D2, D3, D5, D6, D7, D9, D11, D12. Zbyl\u00e9 piny D4, D8 a D10 jsem pou\u017eil na zadn\u00ed \u010derven\u00e1 sv\u011btla a bo\u010dn\u00ed \u017elut\u00e1 sv\u011btla. Vlastn\u00ed realizace byla provedena jako vrab\u010d\u00ed hn\u00edzdo p\u0159\u00edmo na desce Arduina. LED jsem p\u0159ip\u00e1jel p\u0159\u00edmo na Arduino Nano\u00a0a p\u0159ipojil proti zemi pomoc\u00ed rezistor\u016f 220R. Jako vyp\u00edna\u010d jsem pou\u017eil <a href=\"https:\/\/www.puhy.cz\/vypinac-kolebkovy-on-off-1pol-12v-20a-cervena-led-54111.html\">tento model<\/a> s \u010dervenou indika\u010dn\u00ed LED.\u00a0Pochopiteln\u011b by \u0161lo pou\u017e\u00edt v\u0161echny dostupn\u00e9 piny pro b\u011b\u017e\u00edc\u00ed sv\u011btlo, ale jeliko\u017e jsem p\u00e1jel LED p\u0159\u00edmo na Arduino Nano, fyzicky by se mi LED vedle sebe neve\u0161ly. Voln\u00e9 piny 8 a 10 jsem p\u0159ipojil pomoc\u00ed kabl\u00edk\u016f a rezistor\u016f op\u011bt 220R k zadn\u00edm \u010derven\u00fdm LED. Voln\u00fd PIN 4 jsem p\u0159ipojil k bo\u010dn\u00edm \u017elut\u00fdm s\u00e9riov\u011b \u0159azen\u00fdm LED v s\u00e9rii s rezistorem 68R.\u00a0Celek je nap\u00e1jen z 9V baterie a vestav\u011bn do plastov\u00e9ho aut\u00ed\u010dka pomoc\u00ed vrta\u010dky, vrt\u00e1ku a tavn\u00e9 lep\u00edc\u00ed pistole \ud83d\ude42<\/p>\n<h2>Software<\/h2>\n<p>K\u00f3d pro Arduino je velmi jednoduch\u00fd a ur\u010dit\u011b V\u00e1s napadne \u0159ada dal\u0161\u00edch \u00faprav nebo vylep\u0161en\u00ed.<\/p>\n<pre>int pinArray[] = {2, 3, 5, 6, 7, 9, 11, 12};\r\nint count = 0;\r\nint timer = 60;\r\n\r\n<\/pre>\n<p>V prom\u011bnn\u00e9\u00a0pinArray[] je nadefinov\u00e1no pole \u010d\u00edsel pin\u016f, ke kter\u00fdm jsou p\u0159ipojeny \u010derven\u00e9 LED pro efekt be\u017e\u00edc\u00edho sv\u011btla jako v legend\u00e1rn\u00edm Knight Rideru.<\/p>\n<p>D\u00e1le je cyklem nadefinov\u00e1no, \u017ee uveden\u00e9 piny se maj\u00ed chovat jako v\u00fdstupy. Zbyl\u00e9 piny jsou pro p\u0159ehlednost deklarov\u00e1ny zvl\u00e1\u0161\u0165 a pou\u017eil jsem je pro zadn\u00ed \u010derven\u00e1 sv\u011btla a bo\u010dn\u00ed \u017elut\u00e1 sv\u011btla.<\/p>\n<pre>void setup(){\r\n for (count=0;count&lt;8;count++) {\r\n pinMode(pinArray[count], OUTPUT);\r\n }\r\npinMode(4, OUTPUT); \/\/zluta svetla\r\npinMode(8, OUTPUT); \/\/cervene zadni svetlo\r\npinMode(10, OUTPUT); \/\/cervene zadni svetlo\r\n}<\/pre>\n<p>V hlavn\u00ed programov\u00e9 smy\u010dce je prov\u00e1d\u011bno pomoc\u00ed dvou cykl\u016f postupn\u00e9 rozsv\u011bdcen\u00ed a zhas\u00edn\u00e1n\u00ed \u010derven\u00fdch LED. V\u017edy po dob\u011bhnut\u00ed je zm\u011bn\u011bn sm\u011br a jsou zm\u011bn\u011bny i stavy zadn\u00edch \u010derven\u00fdch LED a bo\u010dn\u00edch \u017elut\u00fdch LED.<\/p>\n<pre> void loop() {\r\n for (count=0;count&lt;7;count++) {\r\n digitalWrite(pinArray[count], HIGH);\r\n delay(timer);\r\n digitalWrite(pinArray[count + 1], HIGH);\r\n delay(timer);\r\n digitalWrite(pinArray[count], LOW);\r\n delay(timer*2);\r\n digitalWrite(4, LOW);\r\n digitalWrite(8, LOW);\r\n digitalWrite(10, HIGH);\r\n \r\n }\r\n for (count=7;count&gt;0;count--) {\r\n digitalWrite(pinArray[count], HIGH);\r\n delay(timer);\r\n digitalWrite(pinArray[count - 1], HIGH);\r\n delay(timer);\r\n digitalWrite(pinArray[count], LOW);\r\n delay(timer*2);\r\n digitalWrite(4, HIGH);\r\n digitalWrite(8, HIGH);\r\n digitalWrite(10, LOW);\r\n \r\n }\r\n \r\n }<\/pre>\n<p>Jak to vypad\u00e1 v realit\u011b, ukazuje n\u00e1sleduj\u00edc\u00ed video:<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/QaasuilJFZM\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<h2>\u00a0Seznam sou\u010d\u00e1stek<\/h2>\n<p>Arduino Nano nebo <a href=\"https:\/\/www.puhy.cz\/rozsirujici-deska-arduino-micro-65192-94751.html\">Micro<\/a> 1ks<\/p>\n<p><a href=\"https:\/\/www.puhy.cz\/led-5mm-cervena-2ma-25mcd-30-difuzni-53450.html\">LED dioda \u010derven\u00e1<\/a>\u00a0&#8211; doporu\u010duji \u00faspornou verzi 2mA &#8211;\u00a010ks (nebo <a href=\"https:\/\/www.puhy.cz\/led-5mm-cervena-transparentni-hfr205t-baleni-200ks-122049.html\">cel\u00e9 balen\u00ed 200ks<\/a>)<\/p>\n<p><a href=\"https:\/\/www.puhy.cz\/led-5mm-zluta-2ma-3mcd-590nm-60-l53lyd-53453.html\">LED dioda \u017elut\u00e1<\/a> 2ks<\/p>\n<p><a href=\"https:\/\/www.puhy.cz\/220r-0207-rezistor-0-6w-1-50ppm-52724.html\">Rezistor 220R<\/a> 10ks<\/p>\n<p><a href=\"https:\/\/www.puhy.cz\/68r-0207-rezistor-0-6w-1-50ppm-52718.html\">Rezistor 68R<\/a> 1ks<\/p>\n<p><a href=\"https:\/\/www.puhy.cz\/dvojlinka-2x0-35mm2-22awg-cerveno-cerna-mj1m-54795.html\">Vodi\u010d 2&#215;0,35mm2<\/a> podle pot\u0159eby<\/p>\n<p><a href=\"https:\/\/www.puhy.cz\/vypinac-kolebkovy-on-off-1pol-12v-20a-cervena-led-54111.html\">Vyp\u00edna\u010d<\/a>\u00a01ks<\/p>\n<p><a href=\"https:\/\/www.puhy.cz\/kontakty-na-9v-baterii-clip-i-typ-vyvody-12cm-53984.html\">Konektor na 9V baterii<\/a> 1ks<\/p>\n<p><a href=\"https:\/\/www.puhy.cz\/index.php?main_page=newsearch&amp;q=tavn%C3%A1+pistole&amp;ok=\">Tavn\u00e1 pistole<\/a><\/p>\n<p><a href=\"https:\/\/www.puhy.cz\/index.php?main_page=newsearch&amp;q=lep%C3%ADc%C3%AD+kol%C3%ADk&amp;ok=\">N\u00e1hradn\u00ed n\u00e1pln\u011b do tavn\u00e9 pistole<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>D\u00edky\u00a0p\u00e1r LED diod\u00e1m a Arduinu m\u016f\u017eete o\u017eivit d\u011btem nudn\u00e9 aut\u00ed\u010dko o skv\u011bl\u00e9 sv\u011bteln\u00e9 efekty. Konkr\u00e9tn\u00ed n\u00e1vod na efektn\u00ed b\u011b\u017e\u00edc\u00ed sv\u011btlo, jako v legend\u00e1rn\u00edm Knight Rideru, naleznete v tomto \u010dl\u00e1nku. Hardware 8 \u010derven\u00fdch LED diod jsem p\u0159ipojil na porty D2, D3, D5, D6, D7, D9, D11, D12. Zbyl\u00e9 piny D4, D8 a D10 jsem pou\u017eil na [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[695,14,8],"tags":[47,48,44],"_links":{"self":[{"href":"https:\/\/www.puhy.cz\/blog\/wp-json\/wp\/v2\/posts\/1012"}],"collection":[{"href":"https:\/\/www.puhy.cz\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.puhy.cz\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.puhy.cz\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.puhy.cz\/blog\/wp-json\/wp\/v2\/comments?post=1012"}],"version-history":[{"count":4,"href":"https:\/\/www.puhy.cz\/blog\/wp-json\/wp\/v2\/posts\/1012\/revisions"}],"predecessor-version":[{"id":1018,"href":"https:\/\/www.puhy.cz\/blog\/wp-json\/wp\/v2\/posts\/1012\/revisions\/1018"}],"wp:attachment":[{"href":"https:\/\/www.puhy.cz\/blog\/wp-json\/wp\/v2\/media?parent=1012"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.puhy.cz\/blog\/wp-json\/wp\/v2\/categories?post=1012"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.puhy.cz\/blog\/wp-json\/wp\/v2\/tags?post=1012"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}