{"id":397,"date":"2009-09-21T07:51:18","date_gmt":"2009-09-21T13:51:18","guid":{"rendered":"http:\/\/alliwalk.com\/blog\/?p=397"},"modified":"2009-09-21T21:32:57","modified_gmt":"2009-09-22T03:32:57","slug":"phys-comp-week-2-analog-sensors","status":"publish","type":"post","link":"https:\/\/alliwalk.com\/blog\/2009\/09\/phys-comp-week-2-analog-sensors\/","title":{"rendered":"Phys Comp: Week 2 &#8211; Analog sensors, Part 1"},"content":{"rendered":"<p>This week we worked with analog sensors.<\/p>\n<p>For the lab, I was able to correctly set up the breadboard, Arduino, and potentiometer to create my first analog input. I documented along the way.<\/p>\n<p><a href=\"http:\/\/www.flickr.com\/photos\/alliwalk\/3940515785\/in\/photostream\/\"><img loading=\"lazy\" class=\"alignnone\" title=\"Finished adding a potentiometer\" src=\"http:\/\/farm4.static.flickr.com\/3556\/3940516169_0131a38e6c.jpg\" alt=\"\" width=\"426\" height=\"319\" \/><\/a><\/p>\n<p>Then I made a two-input analog switch with two LEDs as output. Here&#8217;s the code:<\/p>\n<p>int ledPinGreen = 10; \/\/ Green pin<br \/>\nint ledPinRed = 9; \/\/ Red pin<\/p>\n<p>int analogFSRLeft = 0; \/\/ Left analog input<br \/>\nint analogFSRRight = 1; \/\/ Right analog input<\/p>\n<p>int FSRValueLeft = 1; \/\/ Value of the left FSR<br \/>\nint FSRValueRight = 1; \/\/ Value of the right FSR<\/p>\n<p>void setup() {<br \/>\n\/\/ initialize serial communications at 9600 bps:<br \/>\nSerial.begin(9600);<br \/>\n}<br \/>\nvoid loop() {<br \/>\nFSRValueLeft = analogRead(analogFSRLeft); \/\/ read the left FSR value<br \/>\nanalogWrite(ledPinGreen, FSRValueLeft\/4);<br \/>\nSerial.println(FSRValueLeft); \/\/ print the FSR value back to the<\/p>\n<p>FSRValueRight = analogRead(analogFSRRight); \/\/ read the right FSR value<br \/>\nanalogWrite(ledPinRed, FSRValueRight\/4);<br \/>\nSerial.println(FSRValueRight);<\/p>\n<p>delay(10); \/\/ gives a 10 millisecond delay<br \/>\n}<\/p>\n<p><object width=\"425\" height=\"344\" data=\"http:\/\/www.youtube.com\/v\/UuSewfDLAxg&amp;hl=en&amp;fs=1&amp;\" type=\"application\/x-shockwave-flash\"><param name=\"allowFullScreen\" value=\"true\" \/><param name=\"allowscriptaccess\" value=\"always\" \/><param name=\"src\" value=\"http:\/\/www.youtube.com\/v\/UuSewfDLAxg&amp;hl=en&amp;fs=1&amp;\" \/><param name=\"allowfullscreen\" value=\"true\" \/><\/object><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This week we worked with analog sensors. For the lab, I was able to correctly set up the breadboard, Arduino, and potentiometer to create my first analog input. I documented along the way. Then I made a two-input analog switch with two LEDs as output. Here&#8217;s the code: int ledPinGreen = 10; \/\/ Green pin &hellip; <a href=\"https:\/\/alliwalk.com\/blog\/2009\/09\/phys-comp-week-2-analog-sensors\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Phys Comp: Week 2 &#8211; Analog sensors, Part 1&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,1,77,76],"tags":[],"_links":{"self":[{"href":"https:\/\/alliwalk.com\/blog\/wp-json\/wp\/v2\/posts\/397"}],"collection":[{"href":"https:\/\/alliwalk.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alliwalk.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alliwalk.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alliwalk.com\/blog\/wp-json\/wp\/v2\/comments?post=397"}],"version-history":[{"count":8,"href":"https:\/\/alliwalk.com\/blog\/wp-json\/wp\/v2\/posts\/397\/revisions"}],"predecessor-version":[{"id":407,"href":"https:\/\/alliwalk.com\/blog\/wp-json\/wp\/v2\/posts\/397\/revisions\/407"}],"wp:attachment":[{"href":"https:\/\/alliwalk.com\/blog\/wp-json\/wp\/v2\/media?parent=397"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alliwalk.com\/blog\/wp-json\/wp\/v2\/categories?post=397"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alliwalk.com\/blog\/wp-json\/wp\/v2\/tags?post=397"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}