{"id":11,"date":"2012-07-24T10:31:00","date_gmt":"2012-07-24T10:31:00","guid":{"rendered":"http:\/\/192.168.0.199:8000\/?p=9"},"modified":"2023-01-17T15:14:00","modified_gmt":"2023-01-17T14:14:00","slug":"music-level-meter","status":"publish","type":"post","link":"https:\/\/loudat.cz\/kublog\/2012\/07\/24\/music-level-meter\/","title":{"rendered":"Music level meter"},"content":{"rendered":"\n<p>Pot\u011b\u0161en p\u0159edchoz\u00edm pokusem, p\u0159ipojil jsem m\u00edsto potenciometru audio v\u00fdstup z po\u010d\u00edta\u010de. P\u0159idal diody a m\u00edrn\u011b roz\u0161\u00ed\u0159il program. Nejd\u0159\u00edve jsem data nechal pos\u00edlat na s\u00e9riov\u00fd port a op\u011bt dle rozsahu zvolil hodnotu jednotliv\u00fdch krok\u016f p\u0159i kter\u00fdch se rozsv\u011bcuj\u00ed jednotliv\u00e9 diody.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"\" data-line=\"\">int sensorPin = A0; \/\/ select the input pin for the analog input\nint pinArray[] = {2,3,4,5,6,7,8,9,10,11,12,13}; \/\/ array of outputs LED pins\nint count = 0;\nint sensorValue = 0; \/\/ variable to store the value coming from the sensor\n\nvoid setup() { \n\/\/ declare the pinArray as an OUTPUT:\n  for (count=0;count&lt;12;count++) {\n    pinMode(pinArray[count], OUTPUT);\n  }\n}\n\nvoid loop() { \n  \/\/ read the value from the sensor:\n  sensorValue = analogRead(sensorPin); \/\/ we have X LEDs for 0-1024 range of senzorValue\n  if (sensorValue&gt;0){digitalWrite(pinArray[0], HIGH);};\n  if (sensorValue&gt;5){digitalWrite(pinArray[1], HIGH);};\n  if (sensorValue&gt;10){digitalWrite(pinArray[2], HIGH);};\n  if (sensorValue&gt;20){digitalWrite(pinArray[3], HIGH);};\n  if (sensorValue&gt;35){digitalWrite(pinArray[4], HIGH);};\n  if (sensorValue&gt;60){digitalWrite(pinArray[5], HIGH);};\n  if (sensorValue&gt;120){digitalWrite(pinArray[6], HIGH);};\n  if (sensorValue&gt;240){digitalWrite(pinArray[7], HIGH);};\n  if (sensorValue&gt;480){digitalWrite(pinArray[8], HIGH);};\n  if (sensorValue&gt;610){digitalWrite(pinArray[9], HIGH);};\n  if (sensorValue&gt;800){digitalWrite(pinArray[10], HIGH);};\n  if (sensorValue&gt;1000){digitalWrite(pinArray[11], HIGH);};\n  delay(50); \/\/Wait 50ms and turns off all LEDs\n  for (count=0;count&lt;12;count++) {\n    digitalWrite(pinArray[count], LOW);\n  }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Pot\u011b\u0161en p\u0159edchoz\u00edm pokusem, p\u0159ipojil jsem m\u00edsto potenciometru audio v\u00fdstup z po\u010d\u00edta\u010de. P\u0159idal diody a m\u00edrn\u011b roz\u0161\u00ed\u0159il program. Nejd\u0159\u00edve jsem data nechal pos\u00edlat na s\u00e9riov\u00fd port a op\u011bt dle rozsahu zvolil&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","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-11","post","type-post","status-publish","format-standard","hentry","category-arduino"],"_links":{"self":[{"href":"https:\/\/loudat.cz\/kublog\/wp-json\/wp\/v2\/posts\/11","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=11"}],"version-history":[{"count":2,"href":"https:\/\/loudat.cz\/kublog\/wp-json\/wp\/v2\/posts\/11\/revisions"}],"predecessor-version":[{"id":858,"href":"https:\/\/loudat.cz\/kublog\/wp-json\/wp\/v2\/posts\/11\/revisions\/858"}],"wp:attachment":[{"href":"https:\/\/loudat.cz\/kublog\/wp-json\/wp\/v2\/media?parent=11"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/loudat.cz\/kublog\/wp-json\/wp\/v2\/categories?post=11"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/loudat.cz\/kublog\/wp-json\/wp\/v2\/tags?post=11"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}