{"id":3612,"date":"2020-03-31T21:04:54","date_gmt":"2020-03-31T21:04:54","guid":{"rendered":"http:\/\/rodmilstead.com\/pt\/?page_id=3612"},"modified":"2020-03-31T22:31:14","modified_gmt":"2020-03-31T22:31:14","slug":"arduino-photoresistor-setup","status":"publish","type":"page","link":"https:\/\/rodmilstead.com\/pt\/arduino-photoresistor-setup\/","title":{"rendered":"Arduino Photoresistor setup"},"content":{"rendered":"<p><a href=\"http:\/\/rodmilstead.com\/pt\/wp-content\/uploads\/2020\/03\/photores.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-3617 alignleft\" src=\"http:\/\/rodmilstead.com\/pt\/wp-content\/uploads\/2020\/03\/photores.jpg\" alt=\"\" width=\"195\" height=\"125\" srcset=\"https:\/\/rodmilstead.com\/pt\/wp-content\/uploads\/2020\/03\/photores.jpg 628w, https:\/\/rodmilstead.com\/pt\/wp-content\/uploads\/2020\/03\/photores-300x192.jpg 300w\" sizes=\"auto, (max-width: 195px) 100vw, 195px\" \/><\/a>This assignment is an intro to working with a different kind of an input: a photoresistor. Instead of simply pushing a button, a sensor like this makes your program more dynamic.<\/p>\n<p>Photoresistors measure the amount of light; <em>&#8220;A\u00a0<b>photoresistor<\/b>\u00a0is a type of resistor whose resistance decreases when the intensity of light increases. In other words, the flow of electric current through the\u00a0<b>photoresistor <\/b>increases when the intensity of light increases.&#8221;<\/em><\/p>\n<p><strong>So, the more light, the lower the resistance.<\/strong><\/p>\n<p>Photoresistors (also called light dependent) resistors are used to adjust brightness in displays or to cause a streetlight turn on or off when a chosen light level is detected.<\/p>\n<p>This resistance can be measured as a number that the Arduino can read.\u00a0 This number can be used in an if\/else statement with greater than, less than symbols to control when something happens in a program.<\/p>\n<hr \/>\n<p><a href=\"https:\/\/youtu.be\/rhjPCYylCf4\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>Click here for a video description of this assignment.<\/strong><\/a><\/p>\n<p><strong>Here&#8217;s what you have to do (including answering questions about the program and circuit):<\/strong><\/p>\n<ol>\n<li>look at the sample circuit below and build it in Tinkercad.com<\/li>\n<li>copy and paste the sample code (below the image) into your Tinkercad program (delete whatever codes is there first).\u00a0 No typing. <em><strong>Really. Just copy and paste.<\/strong><\/em><\/li>\n<li>Run the program and be sure to click on Serial Monitor below your code.<\/li>\n<li><a href=\"https:\/\/docs.google.com\/forms\/d\/e\/1FAIpQLSfDKS0iBQCMPYDm5g-DCLjKgMvvH9OmQpxH90L-eRMG8ZrKeA\/viewform?usp=sf_link\" target=\"_blank\" rel=\"noopener noreferrer\">Click here to answer questions about your code and circuit.\u00a0 You will also turn in your code URL here.<\/a><\/li>\n<\/ol>\n<p><a href=\"http:\/\/rodmilstead.com\/pt\/wp-content\/uploads\/2020\/03\/Screen-Shot-2020-03-31-at-1.53.28-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-3616\" src=\"http:\/\/rodmilstead.com\/pt\/wp-content\/uploads\/2020\/03\/Screen-Shot-2020-03-31-at-1.53.28-PM.png\" alt=\"\" width=\"675\" height=\"618\" srcset=\"https:\/\/rodmilstead.com\/pt\/wp-content\/uploads\/2020\/03\/Screen-Shot-2020-03-31-at-1.53.28-PM.png 675w, https:\/\/rodmilstead.com\/pt\/wp-content\/uploads\/2020\/03\/Screen-Shot-2020-03-31-at-1.53.28-PM-300x275.png 300w\" sizes=\"auto, (max-width: 675px) 100vw, 675px\" \/><\/a><\/p>\n<p><strong>Copy this sample code and paste into your Photoresistor circuit -don&#8217;t forget to include those two curly braces at the on the last two lines:<\/strong><\/p>\n<p>int light=0;<br \/>\nint lightVal;<br \/>\nint red=13;<\/p>\n<p>void setup()<br \/>\n{<br \/>\npinMode (red, OUTPUT);<br \/>\nSerial.begin(9600);<br \/>\n}<\/p>\n<p>void loop()<br \/>\n{<br \/>\nlightVal = analogRead(light);<br \/>\nSerial.println (lightVal);<br \/>\nif (lightVal&gt;=300)<br \/>\n{<br \/>\ndigitalWrite (red, HIGH);<br \/>\n}<\/p>\n<p>else<br \/>\n{<br \/>\ndigitalWrite (red, LOW);<br \/>\n}<br \/>\n}<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This assignment is an intro to working with a different kind of an input: a photoresistor. Instead of simply pushing a button, a sensor like this makes your program more dynamic. Photoresistors measure the amount of light; &#8220;A\u00a0photoresistor\u00a0is a type of resistor whose resistance decreases when the intensity of light increases. In other words, the &hellip; <a href=\"https:\/\/rodmilstead.com\/pt\/arduino-photoresistor-setup\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Arduino Photoresistor setup<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-3612","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/rodmilstead.com\/pt\/wp-json\/wp\/v2\/pages\/3612","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rodmilstead.com\/pt\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/rodmilstead.com\/pt\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/rodmilstead.com\/pt\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rodmilstead.com\/pt\/wp-json\/wp\/v2\/comments?post=3612"}],"version-history":[{"count":6,"href":"https:\/\/rodmilstead.com\/pt\/wp-json\/wp\/v2\/pages\/3612\/revisions"}],"predecessor-version":[{"id":3620,"href":"https:\/\/rodmilstead.com\/pt\/wp-json\/wp\/v2\/pages\/3612\/revisions\/3620"}],"wp:attachment":[{"href":"https:\/\/rodmilstead.com\/pt\/wp-json\/wp\/v2\/media?parent=3612"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}