{"id":20,"date":"2011-12-16T05:34:26","date_gmt":"2011-12-16T05:34:26","guid":{"rendered":"http:\/\/www.joshuarosenstock.com\/teaching\/IMDG3x00_D11\/?p=20"},"modified":"2018-10-24T03:54:42","modified_gmt":"2018-10-24T03:54:42","slug":"kaiju-video-smasher-software-dev","status":"publish","type":"post","link":"https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/chriswe\/kaiju-video-smasher-software-dev\/","title":{"rendered":"Kaiju Video Smasher &#8211; Software Dev 1"},"content":{"rendered":"<p>With\u00a0the general idea for the patch decided and the sub components outlines, it&#8217;s time to start patching.<\/p>\n<p>Starting the project. I have all the hardware I think I\u2019ll need with me.<\/p>\n<ul>\n<li>A flex sensor<\/li>\n<li>My arduino with protoboard and prototype shield<\/li>\n<li>Access to an old ECE kit full of resistors and such<\/li>\n<\/ul>\n<div>After doing some\u00a0quick google searching for flex sensor and found this handy site: <a href=\"http:\/\/itp.nyu.edu\/physcomp\/sensors\/Reports\/Flex\">http:\/\/itp.nyu.edu\/physcomp\/sensors\/Reports\/Flex<\/a><\/div>\n<div>It has a ton of good info about the use of a flex sensor and some interesting amplifier schematics for filtering the output of the sensor. Since I don\u2019t have access to an opamp, I\u2019ll keep looking for an easier circuit to interface with my arduino.<\/div>\n<div>\n<p>From the product page at sparkfun [<a href=\"http:\/\/www.sparkfun.com\/products\/8606\">http:\/\/www.sparkfun.com\/products\/8606<\/a>] I got a hold of the sensor\u2019s data sheet and with that applied the flat and flexed resistance values to some voltage divider equations I found on this site [<a href=\"http:\/\/protolab.pbworks.com\/w\/page\/19403657\/TutorialSensors\">http:\/\/protolab.pbworks.com\/w\/page\/19403657\/TutorialSensors<\/a>\u00a0scroll down a bit] to calculate the voltages that arduino will measure when the sensor is flat and when it is flexed.\u00a0I just guessed the 1k ohm resistor value, but after chugging through the voltage divider equation, I\u2019ll get around 2.1 volts difference between flat and flexed. That should suffice.<\/p>\n<p>I cobbled\u00a0together\u00a0the circuit defined at the site above so I can start working with the arduino. Here&#8217;s my fritzing layout:<\/p>\n<div id='gallery-1' class='gallery galleryid-20 gallery-columns-2 gallery-size-thumbnail'><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/wp-content\/uploads\/sites\/8\/2011\/12\/flex_layout.png'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/wp-content\/uploads\/sites\/8\/2011\/12\/flex_layout-150x150.png\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/div><\/figure><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/wp-content\/uploads\/sites\/8\/2011\/12\/flex_schem.png'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/wp-content\/uploads\/sites\/8\/2011\/12\/flex_schem-150x150.png\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/div><\/figure><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/wp-content\/uploads\/sites\/8\/2011\/12\/Picture-1.jpg'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/wp-content\/uploads\/sites\/8\/2011\/12\/Picture-1-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/div><\/figure><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/wp-content\/uploads\/sites\/8\/2011\/12\/Picture-2.jpg'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/wp-content\/uploads\/sites\/8\/2011\/12\/Picture-2-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/div><\/figure>\n\t\t<\/div>\n\n<p>Taking the\u00a0\u00a0voltage divider setup and the AnalogInSerialOut sample sketch in the arduino software I have been able to see how the voltage signal from the flex sensor changes as it&#8217;s manipulated. Over the entire range of safe flexibility, the digital values reported from the arduino had a value range from 150 to 600. Since I want a range from 0 to 1024, I&#8217;ll remap the values using <a href=\"http:\/\/processing.org\/reference\/map_.html\">map()<\/a>\u00a0and then send them out as a formatted serial string.<\/p>\n<p>For outputting, my method is super-simple just take the value and print it using Serial.print() in a set format. My printing code is as follows:<\/p>\n<pre>  Serial.print(' '); \/\/ lead with a space\r\n  Serial.print('F'); \/\/ print out value label\r\n  Serial.print(' '); \/\/another space\r\n  Serial.print(outputValue); \/\/ the int flex value\r\n  Serial.print(' '); \/\/ wow, another space\r\n  Serial.print('r'); \/\/ \"newline\"<\/pre>\n<p>The code above ends up printing out things like &#8221; F 730 &#8221; which can be easily parsed in pure data which is what I&#8217;m going to work on next.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>With\u00a0the general idea for the patch decided and the sub components outlines, it&#8217;s time to start patching. Starting the project. I have all the hardware I think I\u2019ll need with me. A flex sensor My arduino with protoboard and prototype shield Access to an old ECE kit full of resistors and such After doing some\u00a0quick&#8230; <\/p>\n<div class=\"link-more\"><a href=\"https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/chriswe\/kaiju-video-smasher-software-dev\/\">Read More<\/a><\/div>\n","protected":false},"author":95,"featured_media":524,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"cybocfi_hide_featured_image":"","footnotes":""},"categories":[9],"tags":[],"class_list":["post-20","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sample-posts"],"jetpack_featured_media_url":"https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/wp-content\/uploads\/sites\/8\/2011\/12\/Picture-1.jpg","_links":{"self":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/wp-json\/wp\/v2\/posts\/20","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/wp-json\/wp\/v2\/users\/95"}],"replies":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/wp-json\/wp\/v2\/comments?post=20"}],"version-history":[{"count":2,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/wp-json\/wp\/v2\/posts\/20\/revisions"}],"predecessor-version":[{"id":527,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/wp-json\/wp\/v2\/posts\/20\/revisions\/527"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/wp-json\/wp\/v2\/media\/524"}],"wp:attachment":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/wp-json\/wp\/v2\/media?parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/wp-json\/wp\/v2\/categories?post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/imgd3200-b18\/wp-json\/wp\/v2\/tags?post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}