{"id":270,"date":"2013-08-02T14:54:00","date_gmt":"2013-08-02T14:54:00","guid":{"rendered":"http:\/\/dbbd.sg\/blog\/uncategorized\/simple-light-meter-arduino-servo-photocell\/"},"modified":"2021-05-15T13:57:31","modified_gmt":"2021-05-15T13:57:31","slug":"simple-light-meter-arduino-servo-photocell","status":"publish","type":"post","link":"https:\/\/dbbd.sg\/blog\/2013\/08\/simple-light-meter-arduino-servo-photocell\/","title":{"rendered":"Simple Light Meter (Arduino + Servo + Photocell)"},"content":{"rendered":"<p>Today I almost attended a <a href=\"http:\/\/codextremeapps.org\/\">24-hour programming contest<\/a> but at the briefing I decided I didn&#8217;t fancy sitting there overnight, or being told where I can go and can&#8217;t. So I simply left. Since the point of me signing up for such an event was mainly to force myself to set aside a little time to figure out how to use Arduino, I sat there for a little while looking up what I was interested in exploring, and went to Sim Lim, where I bought a few bits and bobs and a little servo &#8211; and then went home and made my own dumb experiment&#8230;<\/p>\n<h1>Arduino Uno + Photocell + 1 k\u03a9 Resistor + Small Servo<\/h1>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-2484\" src=\"https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/05\/9420642193_1a6953564b_c.jpg\" width=\"800\" height=\"600\" alt=\"P8024918\" srcset=\"https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/05\/9420642193_1a6953564b_c.jpg 800w, https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/05\/9420642193_1a6953564b_c-300x225.jpg 300w, https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/05\/9420642193_1a6953564b_c-768x576.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>BRIGHT!<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-2485\" src=\"https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/05\/9423426818_fbec96a497_c.jpg\" width=\"800\" height=\"600\" alt=\"P8024919\" srcset=\"https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/05\/9423426818_fbec96a497_c.jpg 800w, https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/05\/9423426818_fbec96a497_c-300x225.jpg 300w, https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/05\/9423426818_fbec96a497_c-768x576.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>DARK&#8230;<\/p>\n<p>Okay this is basically a superbeginner mashup of these two basic tutorials: <a href=\"http:\/\/learn.adafruit.com\/adafruit-arduino-lesson-10-making-sounds\/pseudo-theramin\">Adafruit&#8217;s Making Sounds (Lesson 10)<\/a> + <a href=\"http:\/\/learn.adafruit.com\/adafruit-arduino-lesson-14-servo-motors\/the-breadboard-layout-for-sweep\">Adafruit&#8217;s Servo Motors (lesson 14)<\/a>. Well I guess I gotta start somewhere so don&#8217;t laugh at the simpleness of this. I&#8217;m just writing it out here because I will probably forget it all if I don&#8217;t write it down properly, and god knows actual hardware is an undiscovered country for me.<\/p>\n<pre>#include<\/pre>\n<p>int servoPin = 9;<br \/>\nServo servo;<br \/>\nint angle = 0; \/\/ servo position in degrees<br \/>\nint photocellPin = 0;<\/p>\n<p>void setup()<br \/>\n{<br \/>\nservo.attach(servoPin);<br \/>\n\/\/Serial.begin(9600);<br \/>\n}<\/p>\n<p>void loop()<br \/>\n{<br \/>\nint reading = analogRead(photocellPin);<br \/>\nint newAngle = reading\/3 &#8211; 100;<br \/>\n\/\/Serial.print(newAngle);<br \/>\n\/\/Serial.print(&#8220;n&#8221;);<br \/>\nservo.write(newAngle);<br \/>\ndelay(60);<br \/>\n}<\/p>\n<p><center><iframe loading=\"lazy\" src=\"\/\/www.youtube.com\/embed\/ys6k5vrQ31c\" width=\"640\" height=\"360\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/center><a name=\"fritzing\"><\/a><\/p>\n<h1>Fritzing<\/h1>\n<p>I made a sketch of the above with <a href=\"http:\/\/fritzing.org\/download\/\">Fritzing<\/a>. Fritzing is a useful tool for designers and programmers to design and document their prototypes for pcb boards, arduino-based and other electronics projects. Drag and drop and pull&#8230;<\/p>\n<p><center><img loading=\"lazy\" class=\"alignnone size-full wp-image-2486\" src=\"https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/05\/9427323492_6306d5f238_c.jpg\" width=\"740\" height=\"800\" alt=\"Untitled Sketch_bb\" srcset=\"https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/05\/9427323492_6306d5f238_c.jpg 740w, https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/05\/9427323492_6306d5f238_c-278x300.jpg 278w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/center><img loading=\"lazy\" class=\"alignnone size-full wp-image-2487\" src=\"https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/05\/9427342408_e2e24e4db0_c.jpg\" width=\"800\" height=\"662\" alt=\"Screen Shot 2013-08-03 at 12.00.39 PM.png\" srcset=\"https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/05\/9427342408_e2e24e4db0_c.jpg 800w, https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/05\/9427342408_e2e24e4db0_c-300x248.jpg 300w, https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/05\/9427342408_e2e24e4db0_c-768x636.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p><iframe loading=\"lazy\" src=\"\/\/www.youtube.com\/embed\/Hxhd4HKrWpg\" width=\"640\" height=\"480\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I almost attended a 24-hour programming contest but at the briefing I decided I didn&#8217;t fancy sitting there overnight, or being told where I can go and can&#8217;t. So I simply left. Since the point of me signing up for such an event was mainly to force myself to set aside a little time [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2484,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[536,535,628,537],"jetpack_featured_media_url":"https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/05\/9420642193_1a6953564b_c.jpg","_links":{"self":[{"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/posts\/270"}],"collection":[{"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/comments?post=270"}],"version-history":[{"count":1,"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/posts\/270\/revisions"}],"predecessor-version":[{"id":2488,"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/posts\/270\/revisions\/2488"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/media\/2484"}],"wp:attachment":[{"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/media?parent=270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/categories?post=270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/tags?post=270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}