{"id":974,"date":"2018-07-12T21:17:51","date_gmt":"2018-07-12T21:17:51","guid":{"rendered":"https:\/\/zhutarduino.wordpress.com\/?page_id=974"},"modified":"2019-10-20T18:15:09","modified_gmt":"2019-10-20T18:15:09","slug":"learning-arduino-for-beginners-ep37-photo-interrupters","status":"publish","type":"page","link":"https:\/\/thezhut.com\/?page_id=974","title":{"rendered":"Learning Arduino for beginners EP#37 photo interrupters"},"content":{"rendered":"<h2>In this episode we will take a look at how you can use your Arduino board to get digital and analog readings from a photo interrupter also known as an optical interrupter&#8230;<\/h2>\n<p><iframe loading=\"lazy\" title=\"Learning Arduino for beginners EP#37 photo interrupters\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/sZZCL37-vVs?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<h2>Parts List:<\/h2>\n<p>affiliate links<\/p>\n<p><a href=\"https:\/\/www.amazon.com\/gp\/search\/ref=as_li_qf_sp_sr_il_tl?ie=UTF8&amp;tag=zhut01-20&amp;keywords=arduino board&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=91a73217ed844f2dc68b82d2361e3882\" target=\"_blank\" rel=\"noopener noreferrer\">ARDUINO board<\/a><\/p>\n<p><a href=\"https:\/\/www.amazon.com\/gp\/search\/ref=as_li_qf_sp_sr_il_tl?ie=UTF8&amp;tag=zhut01-20&amp;keywords=photo interrupter&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=9ff5165ff0f2f347533b09d22bbaaea5\" target=\"_blank\" rel=\"noopener noreferrer\">photo interrupter<\/a><\/p>\n<p><a href=\"https:\/\/www.amazon.com\/gp\/search\/ref=as_li_qf_sp_sr_il_tl?ie=UTF8&amp;tag=zhut01-20&amp;keywords=resistors&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=d043743a26519627f8729a26239c5501\" target=\"_blank\" rel=\"noopener noreferrer\">resistors<\/a><\/p>\n<p><a href=\"https:\/\/www.amazon.com\/gp\/search\/ref=as_li_qf_sp_sr_il_tl?ie=UTF8&amp;tag=zhut01-20&amp;keywords=arduino led&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=30141cb0c71b1b7118d22a9131df2f5a\" target=\"_blank\" rel=\"noopener noreferrer\">LED<\/a><\/p>\n<p><a href=\"https:\/\/www.amazon.com\/gp\/search\/ref=as_li_qf_sp_sr_il_tl?ie=UTF8&amp;tag=zhut01-20&amp;keywords=arduino breadboard&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=9a8fb3334ed0bd9196dea77f074faaba\">breadboard<\/a><\/p>\n<p><a href=\"https:\/\/www.amazon.com\/gp\/search\/ref=as_li_qf_sp_sr_il_tl?ie=UTF8&amp;tag=zhut01-20&amp;keywords=arduino jumper wires&amp;index=aps&amp;camp=1789&amp;creative=9325&amp;linkCode=xm2&amp;linkId=d69796d98738b5086703739d4b0386e4\">jumper wires<\/a><\/p>\n<h2>Schematic:<\/h2>\n<p><a href=\"https:\/\/thezhut.com\/wp-content\/uploads\/2018\/07\/photo_schem1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-978\" src=\"https:\/\/thezhut.com\/wp-content\/uploads\/2018\/07\/photo_schem1.jpg?w=300\" alt=\"\" width=\"639\" height=\"543\" srcset=\"https:\/\/thezhut.com\/wp-content\/uploads\/2018\/07\/photo_schem1.jpg 996w, https:\/\/thezhut.com\/wp-content\/uploads\/2018\/07\/photo_schem1-300x255.jpg 300w, https:\/\/thezhut.com\/wp-content\/uploads\/2018\/07\/photo_schem1-768x652.jpg 768w\" sizes=\"auto, (max-width: 639px) 100vw, 639px\" \/><\/a><\/p>\n<h2>ARDUINO Code:<\/h2>\n<p>\/\/analogRead code<\/p>\n<p>int val;<br \/>\nint led=13;<\/p>\n<p>void setup() {<br \/>\nSerial.begin(9600);<br \/>\npinMode (led,OUTPUT);<br \/>\n}<\/p>\n<p>void loop() {<br \/>\nval = (analogRead(A1));<br \/>\nSerial.println(val);<br \/>\nif (val &lt; 500)<br \/>\n{<br \/>\ndigitalWrite(led,HIGH);<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\ndigitalWrite(led,LOW);<br \/>\n}<br \/>\ndelay(250);<\/p>\n<p>}<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>\/\/digitalRead code<\/p>\n<p>int led=13;<\/p>\n<p>void setup() {<\/p>\n<p>pinMode (led,OUTPUT);<br \/>\n}<\/p>\n<p>void loop() {<\/p>\n<p>if (digitalRead(A1) == LOW)<br \/>\n{<br \/>\ndigitalWrite(led,HIGH);<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\ndigitalWrite(led,LOW);<br \/>\n}<\/p>\n<p>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this episode we will take a look at how you can use your Arduino board to get digital and analog readings from a photo interrupter also known as an optical interrupter&#8230; Parts List: affiliate links ARDUINO board photo interrupter &hellip; <a href=\"https:\/\/thezhut.com\/?page_id=974\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":809,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":"","_links_to":"","_links_to_target":""},"class_list":["post-974","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/974","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/thezhut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=974"}],"version-history":[{"count":3,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/974\/revisions"}],"predecessor-version":[{"id":1477,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/974\/revisions\/1477"}],"up":[{"embeddable":true,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/809"}],"wp:attachment":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=974"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}