{"id":12,"date":"2012-07-15T22:43:00","date_gmt":"2012-07-15T21:43:00","guid":{"rendered":"http:\/\/192.168.0.199:8000\/?p=10"},"modified":"2023-01-17T14:58:30","modified_gmt":"2023-01-17T13:58:30","slug":"arduino-analogovy-vstup-digi-vystup","status":"publish","type":"post","link":"https:\/\/loudat.cz\/kublog\/2012\/07\/15\/arduino-analogovy-vstup-digi-vystup\/","title":{"rendered":"Arduino &#8211; analogov\u00fd vstup, digi v\u00fdstup"},"content":{"rendered":"\n<p>Napadlo m\u011b vyzkou\u0161et analogov\u00fd vstup. P\u0159ipojil jsem na n\u011bj tahov\u00fd potenciometr, v\u00fdsledek jsem nechal pos\u00edlat na s\u00e9riov\u00fd port, kde jsem zjistil, \u017ee m\u00e1 rozsah cca 0-1000. Jako v\u00fdstup jsem zvolil p\u011btici LEDek, pro ka\u017edou jsem vy\u010dlenil p\u011btinu nam\u011b\u0159en\u00e9 hodnoty a podle toho nastavil jejich sv\u00edcen\u00ed.<\/p>\n\n\n\n<p>Program tentokr\u00e1t s mal\u00fdm vyu\u017eit\u00edm pole (Array) abych pochopil rozd\u00edl oproti m\u00e9 &#8222;mate\u0159\u0161tin\u011b&#8220; PHP:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"\" data-line=\"\">int sensorPin = A0; \/\/ select the input pin for the potentiometer (or other analog input)\nint pinArray[] = {2,3,4,5,6}; \/\/ array of outputs LED pins\nint count = 0;\nint sensorValue = 0; \/\/ variable to store the value coming from the sensor\n\nvoid setup() { \/\/ declare the pinArray as an OUTPUT:\n  for (count=0; count&lt;6; count++) {\n    pinMode(pinArray[count], OUTPUT);\n  }\n}\n\nvoid loop() { \/\/ read the value from the sensor:\n  sensorValue = analogRead(sensorPin); \/\/ we have 5 LEDs for 0-1000 range of senzorValue\n  if (sensorValue&gt;0){digitalWrite(pinArray[0], HIGH);} \/\/ 1-200 lights 1 LED\n  if (sensorValue&gt;201){digitalWrite(pinArray[1], HIGH);} \/\/ 201-400 lights 2 LED\n  if (sensorValue&gt;401){digitalWrite(pinArray[2], HIGH);} \/\/ 401-600 lights 3 LED\n  if (sensorValue&gt;601){digitalWrite(pinArray[3], HIGH);} \/\/ 601-800 lights 4 LED \n  if (sensorValue&gt;801){digitalWrite(pinArray[4], HIGH);} \/\/ 801-1000 lights 5 LED\n  delay(50);\n  for (count=0;count&lt;6;count++) {\n    digitalWrite(pinArray[count], LOW);\n  }\n}<\/code><\/pre>\n\n\n\n<a style=\"color:white;padding:1em 1em 0.5em 1em;margin-top:.5em;margin-bottom:.5em;background-color:black;\" target=\"_blank\" href=\"https:\/\/wokwi.com\/projects\/354043800157962241\" rel=\"noopener\">Otev\u0159\u00edt projekt v&nbsp;&nbsp;&nbsp;\n<svg postion:relative;top:-8px;width=\"80\" height=\"24\" viewBox=\"0 0 69.532 16.413\"><g fill=\"#fff\"><path d=\"M4.192 15.53c-.63-.737-.765-1.863-.32-2.684.405-.748.346-1.136-.583-3.84-.937-2.73-1.116-3.05-1.935-3.455-1.916-.949-1.765-3.452.242-4 1.892-.518 3.374 1.385 2.418 3.105-.416.75-.36 1.113.593 3.865.969 2.796 1.125 3.072 1.964 3.457 1.192.548 1.62 1.883.969 3.024-.65 1.14-2.566 1.442-3.348.528zm1.912-1.003c.465-.38.426-.796-.103-1.098-.238-.136-.545-.186-.681-.111-.423.23-.407 1.014.025 1.26.226.129.567.106.76-.05zM2.612 4.17c.346-.189.224-1.077-.18-1.308-.337-.192-.995.269-.98.687.013.386.809.812 1.16.621zM11.945 15c-.63-.737-.765-1.863-.32-2.684.405-.748.346-1.136-.583-3.84-.937-2.73-1.116-3.05-1.935-3.455-1.916-.949-1.765-3.452.242-4 1.892-.518 3.374 1.385 2.418 3.105-.416.75-.36 1.113.593 3.865.969 2.796 1.125 3.072 1.964 3.457 1.192.548 1.62 1.883.969 3.024-.65 1.14-2.566 1.442-3.348.528zm1.912-1.003c.465-.38.426-.796-.103-1.098-.238-.136-.545-.186-.681-.111-.423.23-.407 1.014.025 1.26.226.129.567.106.76-.05zM10.365 3.64c.346-.189.224-1.077-.18-1.308-.337-.192-.995.269-.98.687.013.386.809.812 1.16.621z\"><\/path><path d=\"M4.543 16.22c-2.027-1.187-1.3-4.185 1.015-4.185.75 0 .816-.177 1.864-1.169s2.833-2.627 4.035-3.221c.324.459.571 1.614.607 1.748-.773 0-2.75 1.515-3.588 2.537-.81.989-.985 1.4-.928 2.188.052.73-.081 1.111-.542 1.54-.779.729-1.786.958-2.463.562zm1.56-1.695c.215-.56-.025-.902-.634-.902-.594 0-.896.408-.693.938.198.516 1.125.49 1.327-.036zM13.185 12.06s.283-.565 1.392-3.717c1.44-4.077 1.509-4.406 1.096-5.263-.887-1.84.835-3.684 2.691-2.88.694.3.931.585 1.236 1.49.332.983.303 1.19-.244 1.72-.342.331-.896.716-1.232.856-.47.196-.971 1.255-2.185 4.618-1.443 3.997-1.06 2.817-.67 3.541.961 1.79-.26.492-2.084-.365zm5.066-9.85c-.006-.6-.355-.829-.922-.605-.254.101-.485.309-.512.462-.085.474.537.951 1 .768.241-.095.437-.377.434-.624z\"><\/path><g><path d=\"M26.397 15.57q-2.378.363-4.232-.922-1.97-1.37-2.308-3.953-.413-3.147.978-5.985 1.557-3.15 4.441-3.59 2.774-.424 4.3.717 1.592 1.186 1.988 4.205.413 3.147-.84 5.918-1.443 3.17-4.327 3.61zm-.876-12.586q-2.066.315-3.209 2.753-1.057 2.24-.735 4.695.23 1.756 1.58 2.672 1.292.861 2.995.601 2.05-.312 3.09-2.744.928-2.173.602-4.657-.285-2.173-1.303-2.918-.971-.715-3.02-.402zM35.637.98a.872.872 0 00-.652.275.947.947 0 00-.257.671c0 1.224-.039 3.081-.102 5.354.318-.509.773-.846 1.271-.896a2.28 2.28 0 01.467 0 63.88 63.88 0 01.082-1.684c.073-1.255.11-2.18.11-2.774a.93.93 0 00-.267-.67.853.853 0 00-.652-.276zm6.825.156c-.257 0-.49.12-.698.358l-2.636 3.06a52.882 52.882 0 01-1.944 2.099c.547.32.914.88 1.074 1.479.945-.925 1.887-1.847 2.771-2.816 1.58-1.752 2.37-2.83 2.37-3.234a.898.898 0 00-.284-.67.912.912 0 00-.653-.276zm-4.208 8.307c-.12.378-.352.707-.712.92a1.978 1.978 0 01-.754.26l2.33 2.345c1.721 1.635 3.047 2.453 3.978 2.453.264 0 .475-.117.634-.35.129-.19.193-.388.193-.597 0-.447-.242-.75-.726-.91a3.81 3.81 0 01-1.13-.605l-.964-.81a106.213 106.213 0 01-2.849-2.706zm-3.69.229a210.995 210.995 0 00-.093 5.105c0 .294.085.567.257.818.208.306.487.459.836.459.532 0 .8-.303.8-.91l.007-4.509c-.606-.039-1.208-.324-1.664-.783a3.926 3.926 0 01-.143-.18zm1.333-3.288c2.338-.235 3.256 3.024 1.645 3.98-.912.54-2.076.252-2.835-.512-.473-.56-.589-.946-.47-1.564.202-1.047.88-1.826 1.66-1.904zm-.262 2.289c.156.58.552.714 1.044.355.48-.35.484-.858.007-1.167-.464-.3-1.198.267-1.051.812zM57.077 15.93c-.282 0-.53-.08-.744-.239-.245-.184-.367-.41-.367-.68-.282-.74-.46-1.344-.533-1.81-.074-.465-.316-1.784-.726-3.958-.312-1.648-.52-2.97-.625-3.969-.545 2.021-1.13 3.733-1.754 5.135-.723 1.623-1.191 2.894-1.406 3.812.074.141.11.279.11.414 0 .275-.122.502-.367.68-.22.165-.471.248-.753.248-.827 0-1.24-.371-1.24-1.112l-.285-1.167-1.001-4.5c-.398-1.52-1.078-3.697-2.04-6.532a1.225 1.225 0 01-.064-.368c0-.569.322-.854.965-.854.398 0 .704.218.918.652.11.22.334.855.67 1.902.362 1.108.723 2.443 1.085 4.005l.89 4.06c.656-1.519 1.308-3.368 1.957-5.548.399-1.33.702-2.25.91-2.765.551-1.354 1.087-2.03 1.607-2.03.43 0 .732.217.91.652.22.527.444 1.782.67 3.766.123 1.005.331 2.211.625 3.62l.79 3.61c.82-1.972 1.847-4.64 3.077-8.001.068-.184.22-.763.46-1.737.177-.716.395-1.273.652-1.671.22-.337.508-.506.863-.506.619 0 1.643.43 1.643 1.043 0 .104-.813.286-1.009.794l-.367.993-.505 1.635-2.729 6.632c-.25.729-.683 1.788-1.295 3.178-.22.41-.551.616-.992.616z\"><\/path><\/g><path d=\"M67.427 7.01a64.95 64.95 0 00-.211 5.107c0 .43.012.959.037 1.59.024.63.036 1.16.036 1.589-.623 1.156-1.85.737-2.112-.056.165-2.14.17-1.952.165-3.003 0-1.415.086-3.182.257-5.3.955-2.293 2.369-1.893 2.369-1.893.038.758-.579 1.553-.54 1.966zM67.077.33c2.337-.235 3.256 3.024 1.645 3.98-.912.54-2.076.252-2.835-.512-.473-.56-.589-.945-.47-1.564.201-1.047.88-1.826 1.66-1.904zm-.262 2.289c.156.58.551.714 1.043.355.48-.35.484-.858.007-1.167-.463-.3-1.198.267-1.05.812z\"><\/path><\/g><\/svg>&nbsp;&nbsp;,&nbsp;online Arduino a ESP32 simul\u00e1toru<\/b><\/a><br><br>\n\n\n\n<figure class=\"wp-block-video\"><video controls src=\"https:\/\/loudat.cz\/jakub\/wp-content\/uploads\/2012\/07\/2012-07-19-18.44.30.mp4\"><\/video><figcaption class=\"wp-element-caption\"> <\/figcaption><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Napadlo m\u011b vyzkou\u0161et analogov\u00fd vstup. P\u0159ipojil jsem na n\u011bj tahov\u00fd potenciometr, v\u00fdsledek jsem nechal pos\u00edlat na s\u00e9riov\u00fd port, kde jsem zjistil, \u017ee m\u00e1 rozsah cca 0-1000. Jako v\u00fdstup jsem zvolil&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[10],"tags":[],"class_list":["post-12","post","type-post","status-publish","format-standard","hentry","category-arduino"],"_links":{"self":[{"href":"https:\/\/loudat.cz\/kublog\/wp-json\/wp\/v2\/posts\/12","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/loudat.cz\/kublog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/loudat.cz\/kublog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/loudat.cz\/kublog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/loudat.cz\/kublog\/wp-json\/wp\/v2\/comments?post=12"}],"version-history":[{"count":22,"href":"https:\/\/loudat.cz\/kublog\/wp-json\/wp\/v2\/posts\/12\/revisions"}],"predecessor-version":[{"id":850,"href":"https:\/\/loudat.cz\/kublog\/wp-json\/wp\/v2\/posts\/12\/revisions\/850"}],"wp:attachment":[{"href":"https:\/\/loudat.cz\/kublog\/wp-json\/wp\/v2\/media?parent=12"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/loudat.cz\/kublog\/wp-json\/wp\/v2\/categories?post=12"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/loudat.cz\/kublog\/wp-json\/wp\/v2\/tags?post=12"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}