<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>lithium flowers bloom &#187; Introduction to Physical Computing</title>
	<atom:link href="http://leejayxia.com/blog/category/itp/introduction-to-physical-computing/feed/" rel="self" type="application/rss+xml" />
	<link>http://leejayxia.com/blog</link>
	<description>the weblog</description>
	<lastBuildDate>Sat, 15 May 2010 20:52:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Update on Physical Computing Final</title>
		<link>http://leejayxia.com/blog/update-on-physical-computing-final/</link>
		<comments>http://leejayxia.com/blog/update-on-physical-computing-final/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 07:05:19 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[Introduction to Physical Computing]]></category>
		<category><![CDATA[Fall 2008]]></category>
		<category><![CDATA[final]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[magnets]]></category>
		<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[servomotor]]></category>
		<category><![CDATA[wood]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=357</guid>
		<description><![CDATA[I&#8217;ve been working with Liesje on the pcomp final and we had a lot of fun playing with magnets. Now it comes to a crucial question what are we gonna do to put some real pcomp into this project. Finally today we came to narrow down our ideas and focused on a still exciting solution! [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working with Liesje on the pcomp final and we had a lot of fun playing with magnets. Now it comes to a crucial question what are we gonna do to put some real pcomp into this project. Finally today we came to narrow down our ideas and focused on a still exciting solution! We still want to keep the organic look and feel of this piece and we&#8217;re adding a little bit servo-driven motion just to strengthen the interaction and exaggerate the motion of the magnets.</p>
<p>some 3 days ago pictures.</p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2008/12/dsc04929.jpg" rel="lightbox[357]"><img src="http://leejayxia.com/blog/wp-content/uploads/2008/12/dsc04929-300x225.jpg" alt="" title="dsc04929" width="300" height="225" class="alignnone size-medium wp-image-360" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2008/12/dsc04928.jpg" rel="lightbox[357]"><img src="http://leejayxia.com/blog/wp-content/uploads/2008/12/dsc04928-300x225.jpg" alt="" title="dsc04928" width="300" height="225" class="alignnone size-medium wp-image-359" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2008/12/dsc04927.jpg" rel="lightbox[357]"><img src="http://leejayxia.com/blog/wp-content/uploads/2008/12/dsc04927-300x225.jpg" alt="" title="dsc04927" width="300" height="225" class="alignnone size-medium wp-image-358" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/update-on-physical-computing-final/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Proposal for Pcom Final</title>
		<link>http://leejayxia.com/blog/proposal-for-pcom-final/</link>
		<comments>http://leejayxia.com/blog/proposal-for-pcom-final/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 08:48:27 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[Introduction to Physical Computing]]></category>
		<category><![CDATA[Fall 2008]]></category>
		<category><![CDATA[final]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[proposal]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=311</guid>
		<description><![CDATA[The biggest challenge for me so far is to narrow down the options and ideas. The semester is too short to explore everything that interests me, so that makes it even harder to decide on a &#8220;final&#8221; project. Proposal 1: The Sphere I&#8217;m taking the visualizing the five senses class this semester and am always [...]]]></description>
			<content:encoded><![CDATA[<p>The biggest challenge for me so far is to narrow down the options and ideas. The semester is too short to explore everything that interests me, so that makes it even harder to decide on a &#8220;final&#8221; project.</p>
<h2><span style="color: #ff6600;">Proposal 1: The Sphere</span></h2>
<p>I&#8217;m taking the visualizing the five senses class this semester and am always curious about extending the senses by means of physical computing. I couldn&#8217;t be happier if I&#8217;m able to combine these two courses to visualize the sight data and give it a more visually appealing presentation. That&#8217;s how I came up with the idea of &#8220;the sphere&#8221; (sounds like it goes well with my midterm cube).</p>
<p>The sphere is a toy ball mainly with a camera wrapped inside of elastic and transparent material (I don&#8217;t know what&#8217;s that yet). It should be able to be thrown between people and to bounce against walls and floors. It could also serve as a general purpose remote control.</p>
<p>The core of the sphere is composed of following:</p>
<ul>
<li>CMOS camera (which takes pictures!)</li>
<li>microcontroller (controlling everything and serving the data to xbee)</li>
<li>xbee module (talking wirelessly to another peer xbee connected to the computer)</li>
<li>battery (power supply for everything)</li>
<li>suspension system (maybe? foam?)</li>
<li>accelerometer and other potential sensors that are required to fulfill the visualization</li>
<li>wires &#8230; and stuff</li>
</ul>
<p>The ideal size will be a little bigger than the tennis ball and smaller than a volleyball. It&#8217;s encouraged that people can play with the ball in pair or group. Due to the nature of the xbee communication and the fact that it does not have any external memory so it&#8217;s bounded to the computer, it&#8217;s not supposed to be a totally outdoor sport but I think apprently it&#8217;ll take much better pictures with the sunshines outdoor. Anyway the intention is to make the ball as durable as possible and involve as much people interaction as possible. So we&#8217;ll see.</p>
<p>The wrapping material should be:</p>
<ul>
<li>soft</li>
<li>elastic?</li>
<li>transparent (or having a channel for the camera to take pictures)</li>
<li>using force/flex sensor to log enormous shape change</li>
</ul>
<p>Basically I&#8217;m looking for something like rubber but transparent. Not sure if I can find one. If not I will also consider creating a woven structure by vines or bamboo. (<a href="http://leejayxia.com/blog/wp-content/uploads/2008/11/1213769612848_000.jpg" target="_blank" rel="lightbox[311]">pic.</a>)</p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2008/11/sphere_1.jpg" rel="lightbox[311]"><img class="alignnone size-medium wp-image-312" title="sphere_1" src="http://leejayxia.com/blog/wp-content/uploads/2008/11/sphere_1-300x225.jpg" alt="" width="300" height="225" /></a> <a href="http://leejayxia.com/blog/wp-content/uploads/2008/11/sphere_1a.jpg" rel="lightbox[311]"><img class="alignnone size-medium wp-image-313" title="sphere_1a" src="http://leejayxia.com/blog/wp-content/uploads/2008/11/sphere_1a-300x225.jpg" alt="" width="300" height="225" /></a> <a href="http://leejayxia.com/blog/wp-content/uploads/2008/11/sphere_2.jpg" rel="lightbox[311]"><img class="alignnone size-medium wp-image-314" title="sphere_2" src="http://leejayxia.com/blog/wp-content/uploads/2008/11/sphere_2-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>On the other side (the visualization):</p>
<ul>
<li>another xbee module is reading the data in real time to a processing sketch, or whatever client application that logs the data to the file system;</li>
<li>ideally the data would be visualized in real time;</li>
<li>the images taken are arranged in a collage in a virtual 3d space according to the position and orientation while it&#8217;s taken.</li>
<li>data logged with different groups of people playing with the ball could be visualized separately and compared side by side</li>
<li>other 2D visualizations are open options.</li>
</ul>
<p>Since the sphere is designed for general purpose use, the post process could also be extended to music composing, gaming or any other applications that require multidemensional inputs.</p>
<h2><span style="color: #ff6600;">Proposal 2: Physical Interface for a 16&#215;16 (or less) pixel matrix</span></h2>
<p>I don&#8217;t have a very nice name for this piece yet. Basically I&#8217;m inspired by a project called <a href="http://www.youtube.com/watch?v=-lGG3SNXhW0" target="_blank">Shade Pixel</a>. It looks definitely inspired by Rozin&#8217;s wooden mirror though. Similar project called <a href="http://www.freymartin.de/en/projects/snoil/videoflash" target="_blank">SnOil</a> is accomplished with oil and electromagnets. I would like to look for a right fabric to build this surface. Instead of the solenoids I wish to try the electromagnets to pull down the fabric surface, I really don&#8217;t appreciate that cone look of the holes. (link to yet another <a href="http://www.albinkarlsson.com/projects/digital/digitalgoldvideo.html" target="_blank">similar project</a>.)</p>
<p>On the input side, I wish to make a website that allows the visitors to create whatever pattern within that 16&#215;16 matrix in black and white. Whenever there is an update on the website, the physical interface morphs to the new pattern and so on. The inspiration is from one of my favorite simple site <a href="http://tiny.tacolab.com/" target="_blank">tiny</a>.</p>
<p>The biggest challenge is, pretty much the same as previous one, to find out a right material, in this case, for the surface. This point is to break the boundary of the online space and make a change happened in the cyberspace directly impacts the real world. Of course if someone wishes to make it a one way instant message system I&#8217;m still more than happy to see that.</p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/proposal-for-pcom-final/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Everyone with crazy ideas of the keyless entry must be living in a dorm!</title>
		<link>http://leejayxia.com/blog/everyone-with-crazy-ideas-of-the-keyless-entry-must-be-living-in-a-dorm/</link>
		<comments>http://leejayxia.com/blog/everyone-with-crazy-ideas-of-the-keyless-entry-must-be-living-in-a-dorm/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 20:51:15 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[Introduction to Physical Computing]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[keyless entry]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=288</guid>
		<description><![CDATA[I ran into this post today and apparently it&#8217;s a similar but much savvier implementation of my unlocking system. Really like the touch sensor use! What&#8217;s really sad is I was locked again outside my bedroom two weeks ago at midnight. I cannot always stick my arduino to the door. Nice work Alex! Check out [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into <a href="http://students.washington.edu/acleone/projects/door/" target="_blank">this post</a> today and apparently it&#8217;s a similar but much savvier implementation of <a href="http://leejayxia.com/blog/solution-for-lockouts/" target="_blank">my unlocking system</a>.<br />
Really like the touch sensor use!</p>
<p>What&#8217;s really sad is I was locked again outside my bedroom two weeks ago at midnight. I cannot always stick my arduino to the door.</p>
<p>Nice work Alex!</p>
<p>Check out the video below:</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/GU8Ej0c2R14&#038;color1=0xb1b1b1&#038;color2=0xcfcfcf&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/GU8Ej0c2R14&#038;color1=0xb1b1b1&#038;color2=0xcfcfcf&#038;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/everyone-with-crazy-ideas-of-the-keyless-entry-must-be-living-in-a-dorm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UPDATED: Pcom lab catch up and GO OUT</title>
		<link>http://leejayxia.com/blog/pcom-lab-catch-up/</link>
		<comments>http://leejayxia.com/blog/pcom-lab-catch-up/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 15:59:59 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[Introduction to Physical Computing]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[DC motor]]></category>
		<category><![CDATA[Michel Gondry]]></category>
		<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Strand]]></category>
		<category><![CDATA[transister]]></category>
		<category><![CDATA[Week8]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=273</guid>
		<description><![CDATA[The transister lab looks fun because I like these DC motors since young. They have a unique smell while spinning really fast. In my impression they could work very well with just 2 AA battery (3V) in a toy car, so I&#8217;m curious about how would it be with 9 or 12V. First I hooked [...]]]></description>
			<content:encoded><![CDATA[<p>The transister lab looks fun because I like these DC motors since young. They have a unique smell while spinning really fast. In my impression they could work very well with just 2 AA battery (3V) in a toy car, so I&#8217;m curious about how would it be with 9 or 12V.</p>
<p>First I hooked up the circuit according to the website walkthrough, using the 9V output from the arduino. Surprisedly it didn&#8217;t work, even in the simplified program without the potentiameter. I checked the circuit for a couple of times and tried to hook the motor directly to the batteries, 5V from the arduino and 12V from the wall through the adapter, all approaches worked.</p>
<p>It came to me a sad conclusion that the 9V output on my arduino is broken. So I tested the circuit with the 9V from my another arduino and it worked. Is it that the arduino cannot output 5V and 9V at the same time? I haven&#8217;t tested this hypothesis yet.</p>
<p>some photos and videos (the motor was spinning so hard that I had to tape it to the board):</p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04800.jpg" rel="lightbox[273]"><img class="alignnone size-medium wp-image-274" title="dsc04800" src="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04800-300x225.jpg" alt="" width="300" height="225" /> </a><a href="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04801.jpg" rel="lightbox[273]"><img class="alignnone size-medium wp-image-275" title="transister TIP120" src="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04801-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04802.jpg" rel="lightbox[273]"><img class="alignnone size-medium wp-image-276" title="9V power from another arduino" src="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04802-300x225.jpg" alt="" width="300" height="225" /> </a><a href="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04803.jpg" rel="lightbox[273]"><img class="alignnone size-medium wp-image-277" title="transister lab" src="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04803-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="302" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=2100064&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="302" src="http://vimeo.com/moogaloop.swf?clip_id=2100064&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="302" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=2100071&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="302" src="http://vimeo.com/moogaloop.swf?clip_id=2100071&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>I&#8217;l catch up with the H-bridge lab next week.</p>
<p>&#8212;&#8212; a happy going-out seperator &#8212;&#8212;</p>
<p>I was having a group meeting on a short film for commlab and someone just mentioned Michel Gondry while Marco turned around from the table beside and told us that Michel Gondry was going to give a talk right that evening at Strand. I hesitated for a while since I have another project due the next morning, but it was not long. We were really lucky that Marco got us there one hour earlier before the talk started at 7. Huge crowd started to gather since 6:30 and by then we were already sitting within 10 meters from the stage. I did take some photos but the memory card of my phone seems half broken and seriously it does not make much sense to take photo of people in a talk.</p>
<p>The talk started by showing some of Michel&#8217;s recent work, then a short interview between him and his PR guy, and another short video, and another short interview and so on. The screening including some excerpts from his latest film &#8220;be kind rewind&#8221; but my favorite is the music video he did for &#8220;Mad World&#8221; by Gary Jules and Michael Andrews. Not only Donnie Darko is one of my favorite and I love the song SOOOO MUUUCHHH but this music video is so moving and so well made in one long take. It&#8217;s like a combination of all my loved things. Check out the video below:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/Kfcw2yEsabk&amp;hl=en&amp;fs=1" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/Kfcw2yEsabk&amp;hl=en&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Michel also talked about the &#8220;protocal&#8221; of filmmaking and sharing within the community. It&#8217;s more discussed in his new book that I haven&#8217;t read yet so I&#8217;m not sure I totally understand that. He actually accused his PR guy for charging too high on the book (?). And once while Michel is still talking the guy started to check the time, Michel suddenly stopped and turned to him and said &#8220;Don&#8217;t look at your watch while I&#8217;m still talking. It&#8217;s VERY rude.&#8221; It became a little bit awkward in the atmosphere for a while. But I like it.</p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/pcom-lab-catch-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CUBE was not built/burnt in a day</title>
		<link>http://leejayxia.com/blog/cube-was-not-builtburnt-in-a-day/</link>
		<comments>http://leejayxia.com/blog/cube-was-not-builtburnt-in-a-day/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 16:12:27 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[Introduction to Physical Computing]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[cube]]></category>
		<category><![CDATA[Fall 2008]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[microphone]]></category>
		<category><![CDATA[midterm]]></category>
		<category><![CDATA[Physical Computing]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=266</guid>
		<description><![CDATA[ACT 0: BRAINSTORMING THE CUBE ACT 1: ARDUINO ONLY SOUND ANALYSIS pcom midterm: microphone + arduino beat detection from Leejay Xia on Vimeo. pcom midterm: mircophone + arduinobeat detection log from Leejay Xia on Vimeo. ACT 2: THE MACHANICS pcom midterm: the skeleton from Leejay Xia on Vimeo. ACT 3: IT WORKED!!! pcom midterm: rhythm [...]]]></description>
			<content:encoded><![CDATA[<h2>ACT 0: BRAINSTORMING THE CUBE</h2>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04759.jpg" rel="lightbox[266]"><img class="alignnone size-medium wp-image-267" title="dsc04759" src="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04759-300x197.jpg" alt="" width="300" height="197" /></a></p>
<h2>ACT 1: ARDUINO ONLY SOUND ANALYSIS</h2>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="302" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=1997878&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="302" src="http://vimeo.com/moogaloop.swf?clip_id=1997878&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object><br />
<a href="http://vimeo.com/1997878?pg=embed&amp;sec=1997878">pcom midterm: microphone + arduino beat detection</a> from <a href="http://vimeo.com/user758219?pg=embed&amp;sec=1997878">Leejay Xia</a> on <a href="http://vimeo.com?pg=embed&amp;sec=1997878">Vimeo</a>.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="302" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=1997885&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="302" src="http://vimeo.com/moogaloop.swf?clip_id=1997885&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object><br />
<a href="http://vimeo.com/1997885?pg=embed&amp;sec=1997885">pcom midterm: mircophone + arduinobeat detection log</a> from <a href="http://vimeo.com/user758219?pg=embed&amp;sec=1997885">Leejay Xia</a> on <a href="http://vimeo.com?pg=embed&amp;sec=1997885">Vimeo</a>.</p>
<h2>ACT 2: THE MACHANICS</h2>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="302" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=2037455&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="302" src="http://vimeo.com/moogaloop.swf?clip_id=2037455&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object><br />
<a href="http://vimeo.com/2037455?pg=embed&amp;sec=2037455">pcom midterm: the skeleton</a> from <a href="http://vimeo.com/user758219?pg=embed&amp;sec=2037455">Leejay Xia</a> on <a href="http://vimeo.com?pg=embed&amp;sec=2037455">Vimeo</a>.</p>
<h2>ACT 3: IT WORKED!!!</h2>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="302" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=2037479&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="302" src="http://vimeo.com/moogaloop.swf?clip_id=2037479&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object><br />
<a href="http://vimeo.com/2037479?pg=embed&amp;sec=2037479">pcom midterm: rhythm awareness dance pattern</a> from <a href="http://vimeo.com/user758219?pg=embed&amp;sec=2037479">Leejay Xia</a> on <a href="http://vimeo.com?pg=embed&amp;sec=2037479">Vimeo</a>.</p>
<p>on two arduinos:</p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc00454.jpg" rel="lightbox[266]"><img class="alignnone size-medium wp-image-271" title="dsc00454" src="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc00454-300x223.jpg" alt="" width="300" height="223" /></a></p>
<h2>ACT 4: &#8230;UNTIL WE BURNT OUT THE CORE SERVO</h2>
<p>The only motion left was the up-down. But it still works!</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="302" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=2037489&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="302" src="http://vimeo.com/moogaloop.swf?clip_id=2037489&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object><br />
<a href="http://vimeo.com/2037489?pg=embed&amp;sec=2037489">pcom midterm: dance!</a> from <a href="http://vimeo.com/user758219?pg=embed&amp;sec=2037489">Leejay Xia</a> on <a href="http://vimeo.com?pg=embed&amp;sec=2037489">Vimeo</a>.</p>
<h2>ACT 5: NOT THE WORST DANCE IN THE WORLD</h2>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="302" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=2037505&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="302" src="http://vimeo.com/moogaloop.swf?clip_id=2037505&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object><br />
<a href="http://vimeo.com/2037505?pg=embed&amp;sec=2037505">pcom midterm: dance!</a> from <a href="http://vimeo.com/user758219?pg=embed&amp;sec=2037505">Leejay Xia</a> on <a href="http://vimeo.com?pg=embed&amp;sec=2037505">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/cube-was-not-builtburnt-in-a-day/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>PCom Update: multiple serial input</title>
		<link>http://leejayxia.com/blog/multiple-serial-input/</link>
		<comments>http://leejayxia.com/blog/multiple-serial-input/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 06:11:52 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[Introduction to Physical Computing]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Fall 2008]]></category>
		<category><![CDATA[force sensor]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Serial]]></category>
		<category><![CDATA[simulation]]></category>
		<category><![CDATA[Week6]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=238</guid>
		<description><![CDATA[I&#8217;ve been mostly working on viz class and pcom mid term over the weekend. One big thing is I once made the eight-buck-deal RF Link work in the studio, but never succeeded in testing again since I went back to the dorm. I used software serial library to utilize digital pins as serial input/output and [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been mostly working on viz class and pcom mid term over the weekend. One big thing is I once made the eight-buck-deal RF Link work in the studio, but never succeeded in testing again since I went back to the dorm. I used software serial library to utilize digital pins as serial input/output and leave the original serial port for computer monitoring, but the RL Links still feel like a black box to me. The transmitter side looks working perfectly while I hooked up a USB cable and tried to read the TX stream, however the receiver side keeps getting rubbish data. More efforts are to be invested on this issue!!</p>
<p>Just a quick update on the multi-serial-input, shown as the video below (yes I still love my force sensors):</p>
<p><object width="400" height="302"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=1971879&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=1971879&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="302"></embed></object></p>
<p>It&#8217;s pretty simple, just using two serial inputs. But the concept of encoding data and protocol is pretty clear.</p>
<p>Arduino Code:</p>
<div class="codecolorer-container c dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br /></div></td><td><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333;">int</span> leftPin <span style="color: #339933;">=</span> <span style="color: #0000dd;">4</span><span style="color: #339933;">;</span><br />
<span style="color: #993333;">int</span> rightPin <span style="color: #339933;">=</span> <span style="color: #0000dd;">5</span><span style="color: #339933;">;</span><br />
<span style="color: #993333;">int</span> leftValue<span style="color: #339933;">,</span>rightValue<span style="color: #339933;">;</span><br />
<br />
<span style="color: #993333;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; beginSerial<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp;<span style="color: #666666; font-style: italic;">//set up communication back to pc</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; leftValue <span style="color: #339933;">=</span> analogRead<span style="color: #009900;">&#40;</span>leftPin<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; rightValue <span style="color: #339933;">=</span> analogRead<span style="color: #009900;">&#40;</span>rightPin<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
<br />
&nbsp; <span style="color: #666666; font-style: italic;">//if (abs(leftValue - rightValue) &gt; 50)</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">//{</span><br />
&nbsp; &nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span>leftValue<span style="color: #339933;">,</span>DEC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">44</span><span style="color: #339933;">,</span>BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span>rightValue<span style="color: #339933;">,</span>DEC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">44</span><span style="color: #339933;">,</span>BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">//}</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Processing Code:</p>
<div class="codecolorer-container java dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">processing.serial.*</span><span style="color: #339933;">;</span><br />
<br />
Serial myPort<span style="color: #339933;">;</span><br />
<span style="color: #003399;">String</span> data<span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">int</span> leftValue <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">int</span> rightValue <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; size<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">800</span>, <span style="color: #cc66cc;">600</span>, P3D<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; directionalLight<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">126</span>, <span style="color: #cc66cc;">126</span>, <span style="color: #cc66cc;">126</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; ambientLight<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">102</span>, <span style="color: #cc66cc;">102</span>, <span style="color: #cc66cc;">102</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; noStroke<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; myPort <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Serial<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, Serial.<span style="color: #006633;">list</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>, <span style="color: #cc66cc;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; ellipseMode<span style="color: #009900;">&#40;</span>CENTER<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> draw<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; background<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000066; font-weight: bold;">float</span> leftR <span style="color: #339933;">=</span> map<span style="color: #009900;">&#40;</span>leftValue,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1023</span>,<span style="color: #cc66cc;">0</span>,PI<span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000066; font-weight: bold;">float</span> rightR <span style="color: #339933;">=</span> map<span style="color: #009900;">&#40;</span>rightValue,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1023</span>,<span style="color: #cc66cc;">0</span>,PI<span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; translate<span style="color: #009900;">&#40;</span>width<span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span>, height<span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <br />
&nbsp; rotateX<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>PI<span style="color: #339933;">/</span><span style="color: #cc66cc;">12</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; rotateZ<span style="color: #009900;">&#40;</span>rightR <span style="color: #339933;">-</span> leftR<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; stroke<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">160</span>,<span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; fill<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">150</span>,<span style="color: #cc66cc;">150</span>,<span style="color: #cc66cc;">150</span>,<span style="color: #cc66cc;">90</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; box<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">500</span>,<span style="color: #cc66cc;">10</span>,<span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; translate<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <br />
&nbsp; noStroke<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; fill<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; translate<span style="color: #009900;">&#40;</span>map<span style="color: #009900;">&#40;</span>rightValue <span style="color: #339933;">-</span> leftValue,<span style="color: #339933;">-</span><span style="color: #cc66cc;">1023</span>,<span style="color: #cc66cc;">1023</span>,<span style="color: #339933;">-</span><span style="color: #cc66cc;">250</span>,<span style="color: #cc66cc;">250</span><span style="color: #009900;">&#41;</span>,<span style="color: #339933;">-</span><span style="color: #cc66cc;">25</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; sphere<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> serialEvent<span style="color: #009900;">&#40;</span>Serial p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #003399;">String</span> input <span style="color: #339933;">=</span> p.<span style="color: #006633;">readStringUntil</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp;<span style="color: #666666; font-style: italic;">//make sure you return (Ascii 13) at the end of your transmission</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>input <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> parts <span style="color: #339933;">=</span> input.<span style="color: #006633;">split</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp;<span style="color: #666666; font-style: italic;">//this will only work if you put commas (Ascii 44) between things in your transmission</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>parts.<span style="color: #006633;">length</span> <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//println(&quot;Raw Input: &quot; + input);</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>abs<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#40;</span>parts<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> leftValue<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; leftValue <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#40;</span>parts<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>abs<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#40;</span>parts<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> rightValue<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; rightValue <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#40;</span>parts<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/multiple-serial-input/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PCom: Serial Input in Processing</title>
		<link>http://leejayxia.com/blog/serial-input-in-processing/</link>
		<comments>http://leejayxia.com/blog/serial-input-in-processing/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 15:42:33 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[Introduction to Physical Computing]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Fall 2008]]></category>
		<category><![CDATA[force sensor]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Serial]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[Week5]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=229</guid>
		<description><![CDATA[I do enjoy the force sensor I got in week 5&#8242;s application class so I&#8217;ll definitely use it more in the assignment! First I revisited the processing codes I wrote for week 2, which now seems to be a total mess. I didn&#8217;t know about the serialEvent callback then so I parsed the serial input [...]]]></description>
			<content:encoded><![CDATA[<p>I do enjoy the force sensor I got in week 5&#8242;s application class so I&#8217;ll definitely use it more in the assignment!</p>
<p>First I revisited the processing codes I wrote for <a href="http://leejayxia.com/blog/physical-computing-week-2-analog/" target="_blank">week 2</a>, which now seems to be a total mess. I didn&#8217;t know about the serialEvent callback then so I parsed the serial input in the draw loop, and I didn&#8217;t use BYTE output in the arduino board so I need to parse it as string. It worked pretty well but the revised the version is much better.</p>
<p><object width="400" height="302"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=1913389&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=1913389&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="302"></embed></object></p>
<p>Codes:</p>
<div class="codecolorer-container java dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">processing.serial.*</span><span style="color: #339933;">;</span><br />
<br />
Serial myPort<span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">int</span> window <span style="color: #339933;">=</span> <span style="color: #cc66cc;">800</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> values <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">int</span> index <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">int</span> input <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; size<span style="color: #009900;">&#40;</span>window,window<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; background<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; smooth<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">// List all the available serial ports:</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">//println(Serial.list());</span><br />
&nbsp; myPort <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Serial<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, Serial.<span style="color: #006633;">list</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>, <span style="color: #cc66cc;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <br />
&nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; values<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> draw<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; background<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">20</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> i <span style="color: #339933;">+</span> index<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&gt;=</span> <span style="color: #009900;">&#40;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; j <span style="color: #339933;">=</span> j <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; stroke<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">80</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; line<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">50</span> <span style="color: #339933;">+</span> i, <span style="color: #009900;">&#40;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span>, <span style="color: #cc66cc;">50</span> <span style="color: #339933;">+</span> i, <span style="color: #009900;">&#40;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>values<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">1024</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; stroke<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; point<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">50</span> <span style="color: #339933;">+</span> i, <span style="color: #009900;">&#40;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; point<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">50</span> <span style="color: #339933;">+</span> i, <span style="color: #009900;">&#40;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>values<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">1024</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> serialEvent<span style="color: #009900;">&#40;</span>Serial p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; input <span style="color: #339933;">=</span> p.<span style="color: #006633;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; println<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;input:&quot;</span> <span style="color: #339933;">+</span> input<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; values<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> input <span style="color: #339933;">*</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span><br />
&nbsp; index<span style="color: #339933;">++;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>index <span style="color: #339933;">&gt;=</span> window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; index <span style="color: #339933;">=</span> index <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Then I thought about the nature of the force sensor and really wished I could visualize the &#8220;force&#8221; in the processing. So I adopted the &#8220;string&#8221; example bundled in the processing application and integrated it with the serial input.</p>
<p><object width="400" height="302"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=1913399&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=1913399&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="302"></embed></object></p>
<p>Codes:</p>
<div class="codecolorer-container java dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">processing.serial.*</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">// The serial port:</span><br />
Serial myPort<span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">int</span> input <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">int</span> lastInput <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Spring drawing constants for top bar</span><br />
<span style="color: #000066; font-weight: bold;">int</span> s_height <span style="color: #339933;">=</span> <span style="color: #cc66cc;">16</span><span style="color: #339933;">;</span> &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Height</span><br />
<span style="color: #000066; font-weight: bold;">int</span> left <span style="color: #339933;">=</span> <span style="color: #cc66cc;">150</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Left position</span><br />
<span style="color: #000066; font-weight: bold;">int</span> right <span style="color: #339933;">=</span> <span style="color: #cc66cc;">250</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Right position</span><br />
<span style="color: #000066; font-weight: bold;">int</span> max <span style="color: #339933;">=</span> <span style="color: #cc66cc;">300</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Maximum Y value</span><br />
<span style="color: #000066; font-weight: bold;">int</span> min <span style="color: #339933;">=</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// Minimum Y value</span><br />
<span style="color: #000066; font-weight: bold;">boolean</span> over <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span> &nbsp;<span style="color: #666666; font-style: italic;">// If mouse over</span><br />
<span style="color: #000066; font-weight: bold;">boolean</span> move <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span> &nbsp;<span style="color: #666666; font-style: italic;">// If mouse down and over</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Spring simulation constants</span><br />
<span style="color: #000066; font-weight: bold;">float</span> M <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.8</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// Mass</span><br />
<span style="color: #000066; font-weight: bold;">float</span> K <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.2</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// Spring constant</span><br />
<span style="color: #000066; font-weight: bold;">float</span> D <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.92</span><span style="color: #339933;">;</span> &nbsp;<span style="color: #666666; font-style: italic;">// Damping</span><br />
<span style="color: #000066; font-weight: bold;">float</span> R <span style="color: #339933;">=</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">;</span> &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// Rest position</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Spring simulation variables</span><br />
<span style="color: #000066; font-weight: bold;">float</span> ps <span style="color: #339933;">=</span> <span style="color: #cc66cc;">60.0</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Position</span><br />
<span style="color: #000066; font-weight: bold;">float</span> vs <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.0</span><span style="color: #339933;">;</span> &nbsp;<span style="color: #666666; font-style: italic;">// Velocity</span><br />
<span style="color: #000066; font-weight: bold;">float</span> as <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// Acceleration</span><br />
<span style="color: #000066; font-weight: bold;">float</span> f <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Force</span><br />
<br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; size<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">400</span>, <span style="color: #cc66cc;">400</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; rectMode<span style="color: #009900;">&#40;</span>CORNERS<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; noStroke<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; myPort <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Serial<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, Serial.<span style="color: #006633;">list</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>, <span style="color: #cc66cc;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> draw<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; background<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">102</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; updateSpring<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; drawSpring<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> drawSpring<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">// Draw base</span><br />
&nbsp; fill<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0.2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000066; font-weight: bold;">float</span> b_width <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.5</span> <span style="color: #339933;">*</span> ps <span style="color: #339933;">+</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">8</span><span style="color: #339933;">;</span><br />
&nbsp; rect<span style="color: #009900;">&#40;</span>width<span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span> <span style="color: #339933;">-</span> b_width, ps <span style="color: #339933;">+</span> s_height, width<span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span> <span style="color: #339933;">+</span> b_width, <span style="color: #cc66cc;">350</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> updateSpring<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">// Update the spring position</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>move<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; f <span style="color: #339933;">=</span> <span style="color: #339933;">-</span>K <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>ps <span style="color: #339933;">-</span> R<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// f=-ky</span><br />
&nbsp; &nbsp; as <span style="color: #339933;">=</span> f <span style="color: #339933;">/</span> M<span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Set the acceleration, f=ma == a=f/m</span><br />
&nbsp; &nbsp; vs <span style="color: #339933;">=</span> D <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>vs <span style="color: #339933;">+</span> as<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// Set the velocity</span><br />
&nbsp; &nbsp; ps <span style="color: #339933;">=</span> ps <span style="color: #339933;">+</span> vs<span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Updated position</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>abs<span style="color: #009900;">&#40;</span>vs<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">0.1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; vs <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.0</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; <span style="color: #666666; font-style: italic;">// Test if mouse is over the top bar</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; if(mouseX &gt; left &amp;&amp; mouseX &lt; right &amp;&amp; mouseY &gt; ps &amp;&amp; mouseY &lt; ps + s_height) {<br />
&nbsp; &nbsp; over = true;<br />
&nbsp; } else {<br />
&nbsp; &nbsp; over = false;<br />
&nbsp; }<br />
&nbsp; */</span><br />
&nbsp; <br />
&nbsp; <span style="color: #666666; font-style: italic;">// Set and constrain the position of top bar</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>move<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; ps <span style="color: #339933;">=</span> map<span style="color: #009900;">&#40;</span>input,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">255</span>,min,max<span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> s_height<span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ps <span style="color: #339933;">&lt;</span> min<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> ps <span style="color: #339933;">=</span> min<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ps <span style="color: #339933;">&gt;</span> max<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> ps <span style="color: #339933;">=</span> max<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> serialEvent<span style="color: #009900;">&#40;</span>Serial p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; input <span style="color: #339933;">=</span> p.<span style="color: #006633;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; println<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;input:&quot;</span> <span style="color: #339933;">+</span> input<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <br />
&nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>input <span style="color: #339933;">&gt;</span> lastInput<span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; move <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>lastInput <span style="color: #339933;">&gt;</span> input <span style="color: #339933;">+</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">||</span> input <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; move <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; <br />
&nbsp; lastInput <span style="color: #339933;">=</span> input<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/serial-input-in-processing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solution for Lockouts</title>
		<link>http://leejayxia.com/blog/solution-for-lockouts/</link>
		<comments>http://leejayxia.com/blog/solution-for-lockouts/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 07:18:57 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[Introduction to Physical Computing]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Fall 2008]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[lockout]]></category>
		<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[servomotor]]></category>
		<category><![CDATA[Week4]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=192</guid>
		<description><![CDATA[Lockouts are irritating. especially when you live in a dorm, at midnight, your roommate is sleeping, and backup keys are two hours away. Here&#8217;s the self-service solution. I should have made a much more complex combination lock with multiple sensors and flexible customization functionalities, but it&#8217;s two in the morning&#8230; so maybe next time&#8230; Secret [...]]]></description>
			<content:encoded><![CDATA[<p>Lockouts are irritating. especially when you live in a dorm, at midnight, your roommate is sleeping, and backup keys are two hours away. </p>
<p>Here&#8217;s the self-service solution. </p>
<p><object width="400" height="302"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=1856583&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=1856583&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="302"></embed></object></p>
<p>I should have made a much more complex combination lock with multiple sensors and flexible customization functionalities, but it&#8217;s two in the morning&#8230; so maybe next time&#8230;</p>
<p>Secret revealed. </p>
<p><object width="400" height="302"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=1856584&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=1856584&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="302"></embed></object></p>
<p>It&#8217;s kind of low tech in the backstage. All we need are: arduino, plus a servomotor, and, <strong><em>gravity</em></strong>. 8 quarter coins are used as weight. So it&#8217;s basically a two dollar solution! (what? the arduino? breadboard  servomotor and all the lab kits? well&#8230;)</p>
<p>More pictures:</p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04742.jpg" rel="lightbox[192]"><img src="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04742-300x225.jpg" alt="" title="dsc04742" width="300" height="225" class="alignnone size-medium wp-image-200" /></a>&nbsp;<a href="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04741.jpg" rel="lightbox[192]"><img src="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04741-300x225.jpg" alt="" title="dsc04741" width="300" height="225" class="alignnone size-medium wp-image-199" /></a>&nbsp;<a href="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04740.jpg" rel="lightbox[192]"><img src="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04740-300x225.jpg" alt="" title="dsc04740" width="300" height="225" class="alignnone size-medium wp-image-198" /></a></p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04736.jpg" rel="lightbox[192]"><img src="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04736-300x225.jpg" alt="" title="dsc04736" width="300" height="225" class="alignnone size-medium wp-image-195" /></a>&nbsp;<a href="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04737.jpg" rel="lightbox[192]"><img src="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04737-300x225.jpg" alt="" title="dsc04737" width="300" height="225" class="alignnone size-medium wp-image-196" /></a>&nbsp;<a href="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04738.jpg" rel="lightbox[192]"><img src="http://leejayxia.com/blog/wp-content/uploads/2008/10/dsc04738-300x225.jpg" alt="" title="dsc04738" width="300" height="225" class="alignnone size-medium wp-image-197" /></a></p>
<p>bonus video &#8211; playing servomotor with force sensor (warning: not fun to watch at all)</p>
<p><object width="400" height="302"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=1856578&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=1856578&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="302"></embed></object></p>
<p>Thanks Li for the force sensor! We&#8221;ll have to talk!</p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/solution-for-lockouts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Supposed-to-be-easy Electricity Lab</title>
		<link>http://leejayxia.com/blog/electricity-lab/</link>
		<comments>http://leejayxia.com/blog/electricity-lab/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 04:23:43 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[Introduction to Physical Computing]]></category>
		<category><![CDATA[Electricity]]></category>
		<category><![CDATA[Fall 2008]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[Lab]]></category>
		<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Week3]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=156</guid>
		<description><![CDATA[Spent still over two hours though., most of the time tweaking with the multimeter. THE REGULATOR &#160;&#160; Output: 4.97V Input:16.47V Voltage over LED: 2.088V &#8211; over resister: 2.70V LED IN SERIES I don&#8217;t really have much to say about that&#8230; LED A:2.52V LED B:2.48V Seems perfect? Not able to light up 3 LEDs in series [...]]]></description>
			<content:encoded><![CDATA[<p>Spent still over two hours though., most of the time tweaking with the multimeter.</p>
<p><strong>THE REGULATOR</strong><br />
<a href="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04689.jpg" rel="lightbox[156]"><img class="size-medium wp-image-157" title="5V regulator" src="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04689-300x225.jpg" alt="5V regulator setting up" width="300" height="225" /></a>&nbsp;<a href="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04690.jpg" rel="lightbox[156]"><img class="size-medium wp-image-158" title="5V regulator setting up" src="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04690-300x225.jpg" alt="showing switch" width="300" height="225" /></a>&nbsp;<a href="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04691.jpg" rel="lightbox[156]"><img src="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04691-300x225.jpg" alt="" title="Regulator close up" width="300" height="225" class="alignnone size-medium wp-image-159" /></a></p>
<p>Output: 4.97V<br />
Input:16.47V<br />
Voltage over LED: 2.088V<br />
 &#8211; over resister: 2.70V</p>
<p><strong>LED IN SERIES</strong></p>
<p>I don&#8217;t really have much to say about that&#8230;</p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04693.jpg" rel="lightbox[156]"><img src="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04693-300x225.jpg" alt="" title="LED in series" width="300" height="225" class="alignnone size-medium wp-image-160" /></a></p>
<p>LED A:2.52V<br />
LED B:2.48V</p>
<p>Seems perfect? Not able to light up 3 LEDs in series though.</p>
<p><strong>LED IN PARALLEL</strong></p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04695.jpg" rel="lightbox[156]"><img src="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04695-300x225.jpg" alt="" title="LED in parallel setting up" width="300" height="225" class="alignnone size-medium wp-image-161" /></a>&nbsp;<a href="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04696.jpg" rel="lightbox[156]"><img src="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04696-300x225.jpg" alt="" title="LED in parallel" width="300" height="225" class="alignnone size-medium wp-image-162" /></a><br />
<a href="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04699.jpg" rel="lightbox[156]"><img src="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04699-300x225.jpg" alt="" title="Testing current amperage" width="300" height="225" class="alignnone size-medium wp-image-163" /></a>&nbsp;<a href="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04700.jpg" rel="lightbox[156]"><img src="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04700-300x225.jpg" alt="" title="Multimeter out of focus" width="300" height="225" class="alignnone size-medium wp-image-164" /></a></p>
<p>Voltage over resistor: 2.86V<br />
 &#8211; over LED: 2.06V</p>
<p>Amperage calculated: 2.06V / 220 Om = 0.013A<br />
Amperage read from meter: 0.013 &#8211; 0.014A</p>
<p><strong>VARIANT VOLTAGE WITH A POTENTIOMETER</strong></p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04701.jpg" rel="lightbox[156]"><img src="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04701-300x225.jpg" alt="" title="Potentiometer setup" width="300" height="225" class="alignnone size-medium wp-image-165" /></a></p>
<p>Voltage over LED while it&#8217;s:<br />
 &#8211; brightest: 3.00V<br />
 &#8211; medium: 2.60V<br />
 &#8211; dim: 2.43V<br />
 &#8211; off: 2.15V</p>
<p>This well explains why 3 LEDs in series didn&#8217;t work.</p>
<p><object width="400" height="302"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=1800835&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=ff0179&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=1800835&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=ff0179&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="302"></embed></object></p>
<p>Special thanks to <a href="http://neobarc.com/?cat=16" target="_blank">Neo</a> for the power adaptor!</p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/electricity-lab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Physical Computing Week 2: Analog!</title>
		<link>http://leejayxia.com/blog/physical-computing-week-2-analog/</link>
		<comments>http://leejayxia.com/blog/physical-computing-week-2-analog/#comments</comments>
		<pubDate>Wed, 17 Sep 2008 15:11:07 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[Introduction to Physical Computing]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Fall 2008]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Week2]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=100</guid>
		<description><![CDATA[Hooking up the following stuff according to the diagram was easy and quick. And a resister of 220 10K Om is working ideally to create an ouput range of 0 &#8211; 930 (from total darkness to direct shine of torchlight) for the photocell. I changed the switch from last week to a much smaller one [...]]]></description>
			<content:encoded><![CDATA[<p>Hooking up the following stuff according to <a href="http://www.tigoe.net/pcomp/code/input-output/analog-input" target="_blank">the diagram</a> was easy and quick. And a resister of <del datetime="2008-09-18T02:39:37+00:00">220</del> 10K Om is working ideally to create an ouput range of 0 &#8211; 930 (from total darkness to direct shine of torchlight) for the photocell.</p>
<p>I changed the switch from last week to a much smaller one which could be inserted right into the breadboard, to get rid of the mess of the hookup wires. The output was quite straightforward in the arduino console window, so I decided to connect the output to the <a href="http://processing.org/reference/libraries/serial/index.html" target="_blank">processing</a>. </p>
<p>This is how it works:<br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=1750802&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=1750802&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object><br />
<a href="http://vimeo.com/1750802?pg=embed&amp;sec=1750802">Physical Computing Week 2</a> from <a href="http://vimeo.com/user758219?pg=embed&amp;sec=1750802">Leejay Xia</a> on <a href="http://vimeo.com?pg=embed&amp;sec=1750802">Vimeo</a>.</p>
<p>(Quick and Dirty) Code for Processing, it&#8217;s based on the example on their site</p>
<div class="codecolorer-container java dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">processing.serial.*</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// The serial port:</span><br />
Serial myPort<span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">int</span> window <span style="color: #339933;">=</span> <span style="color: #cc66cc;">400</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> values <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">int</span> index <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; size<span style="color: #009900;">&#40;</span>window,window<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; background<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; smooth<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">// List all the available serial ports:</span><br />
&nbsp; println<span style="color: #009900;">&#40;</span>Serial.<span style="color: #006633;">list</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; myPort <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Serial<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, Serial.<span style="color: #006633;">list</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>, <span style="color: #cc66cc;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; values<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> draw<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>myPort.<span style="color: #006633;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> inBuffer <span style="color: #339933;">=</span> myPort.<span style="color: #006633;">readString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> vals <span style="color: #339933;">=</span> splitTokens<span style="color: #009900;">&#40;</span>inBuffer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>vals.<span style="color: #006633;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; values<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#40;</span>vals<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//println(index+&quot;:&quot;+values[index]+&quot;/&quot;+vals[i]);</span><br />
&nbsp; &nbsp; &nbsp; index<span style="color: #339933;">++;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>index <span style="color: #339933;">&gt;=</span> window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; index <span style="color: #339933;">=</span> index <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; background<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> i <span style="color: #339933;">+</span> index<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&gt;=</span> <span style="color: #009900;">&#40;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; j <span style="color: #339933;">=</span> j <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; stroke<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">90</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; line<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">50</span> <span style="color: #339933;">+</span> i, <span style="color: #009900;">&#40;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span>, <span style="color: #cc66cc;">50</span> <span style="color: #339933;">+</span> i, <span style="color: #009900;">&#40;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>values<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">1024</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; stroke<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; point<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">50</span> <span style="color: #339933;">+</span> i, <span style="color: #009900;">&#40;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; point<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">50</span> <span style="color: #339933;">+</span> i, <span style="color: #009900;">&#40;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>values<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>window <span style="color: #339933;">-</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">1024</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Notes-taking:</p>
<ul>
<li> I tried also the Thermistors but have not yet find a right resister to tune its output range.</li>
<li> In the current codes, the arduino board must be plugged before the processing applet runs.<br />
This is because the processing init code cannot find a usable serial port to initialize the object. And so far I didn&#8217;t see a possible way to initialize it during the draw() loop due to the lack of a try/catch machanism. More exploration to go!
</li>
<li>
The serial port transmits data much faster than the draw() function loops. Thus everytime we arrive in the draw() loop there might be a bunch of values waited in the buffer. These values need to be splited and stored accordingly. Of course a more complex protocal could be created to sample specific data or behavior.
</li>
</ul>
<p>More Photos:<br />
<a href="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04616.jpg" rel="lightbox[100]"><img class="alignnone size-medium wp-image-103" title="dsc04616" src="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04616-300x225.jpg" alt="" width="300" height="225" /></a> <a href="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04614.jpg" rel="lightbox[100]"><img class="alignnone size-medium wp-image-101" title="dsc04614" src="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04614-300x225.jpg" alt="" width="300" height="225" /></a> <a href="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04617.jpg" rel="lightbox[100]"><img class="alignnone size-medium wp-image-104" title="dsc04617" src="http://leejayxia.com/blog/wp-content/uploads/2008/09/dsc04617-300x225.jpg" alt="" width="300" height="225" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/physical-computing-week-2-analog/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

