{"id":644,"date":"2009-09-24T11:12:22","date_gmt":"2009-09-24T16:12:22","guid":{"rendered":"http:\/\/itp.indiamos.com\/blog\/?p=644"},"modified":"2017-12-28T00:48:41","modified_gmt":"2017-12-28T05:48:41","slug":"living-in-interesting-times","status":"publish","type":"post","link":"https:\/\/itp.indiamos.com\/blog\/2009\/09\/24\/living-in-interesting-times\/","title":{"rendered":"Living in uninteresting times"},"content":{"rendered":"<p><a href=\"http:\/\/www.flickr.com\/photos\/indiamos\/3960121864\/\" title=\"don\u2019t press the red button by indiamos, on Flickr\"><img loading=\"lazy\" src=\"https:\/\/i1.wp.com\/farm3.static.flickr.com\/2511\/3960121864_ea00f0f92a.jpg?resize=474%2C356\" width=\"474\" height=\"356\" alt=\"don\u2019t press the red button\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p>This week&#8217;s assignment for <a href=\"http:\/\/www.faludi.com\/teaching\/crafting-with-data\/syllabus-crafting-with-data\/\">Crafting with Data<\/a> was<\/p>\n<blockquote><p>Use an Arduino to gather 500 samples of interesting data in two different conditions (1000 samples total). Post your data online so it can be downloaded.<\/p><\/blockquote>\n<p>Now, see, I did this assignment uncharacteristically promptly\u2014days ago!\u2014without having noticed the adjective <em>interesting<\/em>, so originally what I had was some profoundly dull numbers from a thermistor, measured (a) <a href=\"http:\/\/itp.indiamos.com\/crafting\/thermistor_lamp.csv\">under my fluorescent proofreading lamp<\/a> and (b) <a href=\"http:\/\/itp.indiamos.com\/crafting\/thermistor_held.csv\">while I held the sensor between my fingers<\/a>. You will thank me, therefore, for rereading the assignment, noting my error, and, at the last minute, using the Pong controller I made for Understanding Networks to gather some slightly less dull information from the <i>x<\/i> axis of an accelerometer: (a) <a href=\"http:\/\/itp.indiamos.com\/crafting\/accelerometer_floor.csv\">walking on level floor<\/a>, and (b) <a href=\"http:\/\/itp.indiamos.com\/crafting\/accelerometer_stairs.csv\">climbing up and down stairs<\/a>.<\/p>\n<p>Now, with charts!<\/p>\n<p><a href=\"https:\/\/i2.wp.com\/itp.indiamos.com\/blog\/wp-content\/uploads\/2009\/09\/accelerometer_floor_newline.png\"><img loading=\"lazy\" src=\"https:\/\/i2.wp.com\/itp.indiamos.com\/blog\/wp-content\/uploads\/2009\/09\/accelerometer_floor_newline-400x264.png?resize=400%2C264\" alt=\"accelerometer readings while walking on level floor\" title=\"accelerometer readings while walking on level floor\" width=\"400\" height=\"264\" class=\"alignnone size-medium wp-image-667\" srcset=\"https:\/\/i2.wp.com\/itp.indiamos.com\/blog\/wp-content\/uploads\/2009\/09\/accelerometer_floor_newline.png?w=400&amp;ssl=1 400w, https:\/\/i2.wp.com\/itp.indiamos.com\/blog\/wp-content\/uploads\/2009\/09\/accelerometer_floor_newline.png?w=900&amp;ssl=1 900w\" sizes=\"(max-width: 400px) 100vw, 400px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p><a href=\"https:\/\/i1.wp.com\/itp.indiamos.com\/blog\/wp-content\/uploads\/2009\/09\/accelerometer_stairs_newline.png\"><img loading=\"lazy\" src=\"https:\/\/i2.wp.com\/itp.indiamos.com\/blog\/wp-content\/uploads\/2009\/09\/accelerometer_stairs_newline-400x264.png?resize=400%2C264\" alt=\"accelerometer readings while climbing stairs\" title=\"accelerometer readings while climbing stairs\" width=\"400\" height=\"264\" class=\"alignnone size-medium wp-image-668\" srcset=\"https:\/\/i1.wp.com\/itp.indiamos.com\/blog\/wp-content\/uploads\/2009\/09\/accelerometer_stairs_newline.png?w=400&amp;ssl=1 400w, https:\/\/i1.wp.com\/itp.indiamos.com\/blog\/wp-content\/uploads\/2009\/09\/accelerometer_stairs_newline.png?w=900&amp;ssl=1 900w\" sizes=\"(max-width: 400px) 100vw, 400px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p>The guts of my beautiful data collection device look like this:<\/p>\n<p><a href=\"http:\/\/www.flickr.com\/photos\/indiamos\/3960123290\/\" title=\"Pong controller guts by indiamos, on Flickr\"><img loading=\"lazy\" src=\"https:\/\/i0.wp.com\/farm3.static.flickr.com\/2583\/3960123290_117c05e88d.jpg?resize=474%2C356\" width=\"474\" height=\"356\" alt=\"Pong controller guts\" data-recalc-dims=\"1\" \/><\/a><br \/>\n(Click the photo for more details at Flickr.)<\/p>\n<p>I used two Processing sketches\u2014for the thermistor data, <a href=\"http:\/\/www.faludi.com\/classes\/craftingwithdata09\/code\/datalogger_continuous_faludi.pde\">Rob&#8217;s code<\/a>; for the accelerometer data, a quick-and-dirty mod of the almost wholly unoriginal code I used for the Understanding Networks assignment.<\/p>\n<p>[java]<br \/>\n\/*<br \/>\n Serial String Reader + Simple net Client<br \/>\n Language: Processing<\/p>\n<p> Reads in a string of characters from a serial port until<br \/>\n it gets a linefeed (ASCII 10).  Then splits the string into<br \/>\n sections separated by commas. Then converts the sections to ints,<br \/>\n and prints them out.<\/p>\n<p> * Starts a network client that connects to a server on port 8080,<br \/>\n * sends any keystrokes pressed.<\/p>\n<p> created 2 Jun 2005<br \/>\n modified 6 Aug 2008<br \/>\n by Tom Igoe<br \/>\n modified 24 September 2009 by India Amos<br \/>\n *\/<\/p>\n<p>import processing.serial.*;     \/\/ import the Processing serial library<br \/>\nimport processing.net.*;        \/\/ import the Processing networking library<\/p>\n<p>Serial myPort;                  \/\/ The serial port<\/p>\n<p>Client myClient;                   \/\/ instance of the net Client<br \/>\nString data;                       \/\/ string to hold incoming data<br \/>\nString ipAddress = &#8220;128.122.151.178&#8221;;    \/\/ address of the server<br \/>\nString myKey1;                   \/\/ the virtual keypress generated by the x-pin of the accelerometer<br \/>\nString myKey2;                   \/\/ the virtual keypress generated by the y-pin of the accelerometer<br \/>\nString myKey3;                   \/\/ the virtual keypress generated by the switch<br \/>\nString myKeyBuffer;              \/\/ all the virtual keys pressed by a single bleat from the Arduino <\/p>\n<p>float bgcolor;\t\t        \/\/ Background color<\/p>\n<p>void setup() {<br \/>\n  \/\/ establish the background and foreground:<br \/>\n  size(200, 200);<br \/>\n  background(50);<br \/>\n  fill(200);<\/p>\n<p>  \/\/ Connect to server on port 8080<br \/>\n  myClient = new Client(this, ipAddress, 8080);<\/p>\n<p>  \/\/ List all the available serial ports<br \/>\n  println(Serial.list());<\/p>\n<p>  \/\/ I know that the first port in the serial list on my mac<br \/>\n  \/\/ is always my  Arduino module, so I open Serial.list()[0].<br \/>\n  \/\/ Change the 0 to the appropriate number of the serial port<br \/>\n  \/\/ that your microcontroller is attached to.<br \/>\n  myPort = new Serial(this, Serial.list()[0], 9600);<\/p>\n<p>  \/\/ read bytes into a buffer until you get a linefeed (ASCII 10):<br \/>\n  myPort.bufferUntil(&#8216;\\n&#8217;);<br \/>\n}<\/p>\n<p>void draw() {<br \/>\n}<\/p>\n<p>\/\/ serialEvent  method is run automatically by the Processing applet<br \/>\n\/\/ whenever the buffer reaches the  byte value set in the bufferUntil()<br \/>\n\/\/ method in the setup():<\/p>\n<p>void serialEvent(Serial myPort) {<br \/>\n  \/\/ read the serial buffer:<br \/>\n  String myString = myPort.readStringUntil(&#8216;\\n&#8217;);<br \/>\n  \/\/ if you got any bytes other than the linefeed:<br \/>\n  if (myString != null) {<\/p>\n<p>    myString = trim(myString);<\/p>\n<p>    \/\/ split the string at the commas<br \/>\n    \/\/ and convert the sections into integers:<br \/>\n    int sensors[] = int(split(myString, &#8216;\\t&#8217;));<\/p>\n<p>    \/\/ print out the values you got:<br \/>\n    for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {\n      print(\"Sensor \" + sensorNum + \": \" + sensors[sensorNum] + \"\\t\"); \n    }\n    \/\/ add a linefeed after all the sensor values are printed:\n    println();\n\n    \/\/ Convert integers into behavior.\n    \/\/ A change of +\/-50 on sensor 1 means a roll forward (down) or backward (up), respectively. Flat is 520.\n    \/\/ A change of +\/-50 on sensor 2 means a tilt coounter-clockwise or clockwise, respectively. Flat is 505.\n\n    myKey1=\"\";\n    myKey2=\"\";\n    myKey3=\"\";\n\n    if (sensors[0] > 570) \/\/ rolling forward, so paddle down<br \/>\n    {<br \/>\n      myKey1 = &#8220;d&#8221;;<br \/>\n    }<\/p>\n<p>    if (sensors[0] < 470) \/\/ rolling backward, so paddle up\n    {\n      myKey1 = \"u\";\n    }\n\n    if (sensors[1] > 555) \/\/ rolling counter-clockwise, so paddle left<br \/>\n    {<br \/>\n      myKey2 = &#8220;l&#8221;;<br \/>\n    }<\/p>\n<p>    if (sensors[1] < 455) \/\/ rolling clockwise, so paddle right\n    {\n      myKey2 = \"r\";\n    }\n\n    if (sensors[3] > 0 ) \/\/ button pressed<br \/>\n    {<br \/>\n      myKey3 = &#8220;x&#8221;;<br \/>\n    }<\/p>\n<p>    myKeyBuffer = myKey1+myKey2+myKey3;<br \/>\n    println(myKeyBuffer);<\/p>\n<p>    \/\/ If there&#8217;s incoming data from the client:<\/p>\n<p>    if (myClient.available() > 0) {<br \/>\n      \/\/ get the data:<br \/>\n      data = myClient.readString();<br \/>\n      println(data);<br \/>\n    }<\/p>\n<p>    if (myKeyBuffer != null) {<br \/>\n      \/\/ send out anything that&#8217;s typed:<br \/>\n      myClient.write(myKeyBuffer);<br \/>\n    }<br \/>\n if (keyPressed) {<br \/>\n   \/\/ send out anything that&#8217;s typed:<br \/>\n  myClient.write(key);<br \/>\n }<\/p>\n<p>  }<\/p>\n<p>}<br \/>\n[\/java]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This week&#8217;s assignment for Crafting with Data was Use an Arduino to gather 500 samples of interesting data in two different conditions (1000 samples total). Post your data online so it can be downloaded. Now, see, I did this assignment uncharacteristically promptly\u2014days ago!\u2014without having noticed the adjective interesting, so originally what I had was some &hellip; <a href=\"https:\/\/itp.indiamos.com\/blog\/2009\/09\/24\/living-in-interesting-times\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Living in uninteresting times<\/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,42,11,4],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3qY10-ao","_links":{"self":[{"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/posts\/644"}],"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=644"}],"version-history":[{"count":12,"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/posts\/644\/revisions"}],"predecessor-version":[{"id":940,"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/posts\/644\/revisions\/940"}],"wp:attachment":[{"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/media?parent=644"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/categories?post=644"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/tags?post=644"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}