{"id":108,"date":"2008-10-09T08:54:11","date_gmt":"2008-10-09T12:54:11","guid":{"rendered":"http:\/\/itp.indiamos.com\/blog\/?p=108"},"modified":"2008-10-09T22:12:27","modified_gmt":"2008-10-10T02:12:27","slug":"physcomp-week-5-serial-out","status":"publish","type":"post","link":"https:\/\/itp.indiamos.com\/blog\/2008\/10\/09\/physcomp-week-5-serial-out\/","title":{"rendered":"PhysComp, week 5: Serial Out"},"content":{"rendered":"<p><a href=\"https:\/\/i2.wp.com\/itp.indiamos.com\/blog\/wp-content\/uploads\/picture-7.png\"><img loading=\"lazy\" src=\"https:\/\/i2.wp.com\/itp.indiamos.com\/blog\/wp-content\/uploads\/picture-7.png?resize=474%2C353\" alt=\"\" title=\"Serial out graph\" width=\"474\" height=\"353\" class=\"alignnone size-full wp-image-109\" srcset=\"https:\/\/i2.wp.com\/itp.indiamos.com\/blog\/wp-content\/uploads\/picture-7.png?w=480&amp;ssl=1 480w, https:\/\/i2.wp.com\/itp.indiamos.com\/blog\/wp-content\/uploads\/picture-7.png?resize=400%2C297&amp;ssl=1 400w\" sizes=\"(max-width: 474px) 100vw, 474px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p>I was <em>trying<\/em> to figure out the math to make part of the graph show up as brown&#8212;i.e., earth&#8212;and then scatter flowers on top, but something wasn&#8217;t working out and I was running late, so I gave up.<\/p>\n<p>Anyway, here are the progress shots:<\/p>\n<p>Setup:<br \/>\n<a href=\"http:\/\/www.flickr.com\/photos\/indiamos\/2926906248\/\" title=\"P1000190.JPG by indiamos, on Flickr\"><img loading=\"lazy\" src=\"https:\/\/i1.wp.com\/farm4.static.flickr.com\/3098\/2926906248_38d7beec10_m.jpg?resize=240%2C180\" width=\"240\" height=\"180\" alt=\"P1000190.JPG\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p>Pot hooked up:<br \/>\n<a href=\"http:\/\/www.flickr.com\/photos\/indiamos\/2926907936\/\" title=\"P1000199.JPG by indiamos, on Flickr\"><img loading=\"lazy\" src=\"https:\/\/i1.wp.com\/farm4.static.flickr.com\/3239\/2926907936_52047b2cea_m.jpg?resize=240%2C180\" width=\"240\" height=\"180\" alt=\"P1000199.JPG\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p>Blinking LED:<br \/>\n<a href=\"http:\/\/www.flickr.com\/photos\/indiamos\/2926055893\/\" title=\"P1000204.JPG by indiamos, on Flickr\"><img loading=\"lazy\" src=\"https:\/\/i2.wp.com\/farm4.static.flickr.com\/3269\/2926055893_09a3388587_m.jpg?resize=240%2C180\" width=\"240\" height=\"180\" alt=\"P1000204.JPG\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p>I also shot a <em>fascinating<\/em> movie of the program loading on the Arduino and starting up&#8212;you know, flickering yellow light, then blinking LED; hot stuff:<\/p>\n<p>Final code on Arduino:<\/p>\n<blockquote><p><code>int potPin = 0;<br \/>\nint potValue = 0;<br \/>\nint ledPin = 2;<\/p>\n<p>void setup()<br \/>\n{<br \/>\n  \/\/ flash LED three times to announce start of program<br \/>\n  pinMode( 2, OUTPUT );<br \/>\n  digitalWrite( 2, LOW );<br \/>\n  delay( 500 );<br \/>\n  digitalWrite( 2, HIGH );<br \/>\n  delay( 500 );<br \/>\n  digitalWrite( 2, LOW );<br \/>\n  delay( 500 );<br \/>\n  digitalWrite( 2, HIGH );<br \/>\n  delay( 500 );<br \/>\n  digitalWrite( 2, LOW );<br \/>\n  delay( 500 );<br \/>\n  digitalWrite( 2, HIGH );<br \/>\n  delay( 500 );<br \/>\n  digitalWrite( 2, LOW );<br \/>\n  delay( 500 );<br \/>\n  digitalWrite( 2, HIGH );<\/p>\n<p>  \/\/ start serial port at 9600 bps:<br \/>\n  Serial.begin( 9600 );<br \/>\n}<\/p>\n<p>void loop()<br \/>\n{<br \/>\n  \/\/ read analog input, divide by 4 to fit it in the range 0-255:<br \/>\n  potValue = analogRead( potPin );<br \/>\n  potValue = potValue \/ 4;<br \/>\n  Serial.print( potValue, BYTE );<br \/>\n  \/\/ pause for 10 milliseconds:<br \/>\n  delay( 10 );<br \/>\n}<br \/>\n<\/code><\/p><\/blockquote>\n<p><a href=\"http:\/\/itp.indiamos.com\/PhysComp\/week5\/graph_serial_from_pot\/applet\/\">Final Processing applet<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was trying to figure out the math to make part of the graph show up as brown&#8212;i.e., earth&#8212;and then scatter flowers on top, but something wasn&#8217;t working out and I was running late, so I gave up. Anyway, here are the progress shots: Setup: Pot hooked up: Blinking LED: I also shot a fascinating &hellip; <a href=\"https:\/\/itp.indiamos.com\/blog\/2008\/10\/09\/physcomp-week-5-serial-out\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">PhysComp, week 5: Serial Out<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[12,11,4,8,6,9,10],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3qY10-1K","_links":{"self":[{"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/posts\/108"}],"collection":[{"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/comments?post=108"}],"version-history":[{"count":3,"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/posts\/108\/revisions"}],"predecessor-version":[{"id":117,"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/posts\/108\/revisions\/117"}],"wp:attachment":[{"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/media?parent=108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/categories?post=108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/tags?post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}