<?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; simulation</title>
	<atom:link href="http://leejayxia.com/blog/tag/simulation/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>Automating The Brush Stroke</title>
		<link>http://leejayxia.com/blog/automating-the-brush-stroke/</link>
		<comments>http://leejayxia.com/blog/automating-the-brush-stroke/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 18:40:40 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[Drawing Machine]]></category>
		<category><![CDATA[drawing]]></category>
		<category><![CDATA[Fall 2009]]></category>
		<category><![CDATA[final]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[simulation]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=764</guid>
		<description><![CDATA[Here&#8217;s a rough diagram of the drawing machine architecture that I have in mind. I&#8217;m building the components from bottom to top. I moved on from the brush stroke and started to work on a set of drawing functions that incorporate the stroke. Currently coverage: moveTo, lineTo, rect, circle the moveTo function is necessary since [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a rough diagram of the drawing machine architecture that I have in mind. I&#8217;m building the components from bottom to top.</p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2009/11/Drawing-Machine.png" rel="lightbox[764]"><img src="http://leejayxia.com/blog/wp-content/uploads/2009/11/Drawing-Machine-300x149.png" alt="Drawing Machine" title="Drawing Machine" width="300" height="149" class="alignnone size-medium wp-image-767" /></a></p>
<p>I moved on from the brush stroke and started to work on a set of drawing functions that incorporate the stroke. </p>
<p>Currently coverage:</p>
<ul>
<li>moveTo,	</li>
<li>lineTo,</li>
<li>rect,</li>
<li>circle</li>
</ul>
<p>the moveTo function is necessary since the dynamics of the brush motion would depend on the last stroke, both position and speed.</p>
<p>currently i&#8217;m working on the curve function, it&#8217;s quite a challenge to get the brush movement natural enough and calculation is also dependent on the stroke length and brush size too. once this is done I think all basic drawing functions are covered for now and I will move onto the composition stage.</p>
<p>this is a simple test:</p>
<p><object width="603" height="358"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=7675016&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=7675016&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="603" height="358"></embed></object>
<p><a href="http://vimeo.com/7675016">stroke update</a> from <a href="http://vimeo.com/liangjie">Liangjie Xia</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/automating-the-brush-stroke/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perlin Noise Flow Field and Smoky Ribbon</title>
		<link>http://leejayxia.com/blog/perlin-noise-flow-field-and-smoky-ribbon/</link>
		<comments>http://leejayxia.com/blog/perlin-noise-flow-field-and-smoky-ribbon/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 22:11:26 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[The Nature of Code]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[midterm]]></category>
		<category><![CDATA[nature of code]]></category>
		<category><![CDATA[Perlin Noise]]></category>
		<category><![CDATA[simulation]]></category>
		<category><![CDATA[wallpaper]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=486</guid>
		<description><![CDATA[My take into the midterm for Nature of Code started from aimless playing with some old codes I made a couple of weeks ago. Not having a concrete idea of a &#8220;project&#8221; proposal, I decided to apply a Perlin Noise flow field to the fluid pluses I made last week, so that I need not [...]]]></description>
			<content:encoded><![CDATA[<p>My take into the midterm for Nature of Code started from aimless playing with some old codes I made <a href="http://leejayxia.com/blog/playing-with-fluid-simulation/">a couple of weeks ago</a>. Not having a concrete idea of a &#8220;project&#8221; proposal, I decided to apply a Perlin Noise flow field to the fluid pluses I made last week, so that I need not necessarily introduce the mouse move to play with the field. The flow field reinitiates itself every 120 frames so that the particles keep moving and not getting too boring to look at.</p>
<p><object width="640" height="427"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3449357&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3449357&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="640" height="427"></embed></object></p>
<p>Applet on OpenProcessing: <a href="http://openprocessing.org/visuals/?visualID=1094">http://openprocessing.org/visuals/?visualID=1094</a></p>
<p>After constructing the flow field, I came across Anthony Mattox&#8217;s <a href="http://www.anthonymattox.com/perlin-flow-ribbons">Perlin Flow Ribbons</a> which is amazingly attractive to me.Two levels of Perlin Noise field might be a good solution to make the field evolve more fluidly but I just didn&#8217;t do it&#8230; I just left the particles there and let them trace overtime. The results are &#8230; fairly good I shall say. Some of them do look pretty good, others are going bizarre due to lack of control. However the subtle motions overtime are charming to watch. I just sat there for hours staring at the screen (making screenshots) &#8230;</p>
<p><object width="640" height="480"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3449785&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3449785&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="640" height="480"></embed></object></p>
<p>Applet on OpenProcessing: <a href="http://openprocessing.org/visuals/?visualID=1095">http://openprocessing.org/visuals/?visualID=1095</a></p>
<p>More Pic:<br />
<a href="http://leejayxia.com/blog/wp-content/uploads/2009/03/00001007.png" rel="lightbox[486]"><img src="http://leejayxia.com/blog/wp-content/uploads/2009/03/00001007-300x168.png" alt="00001007" title="00001007" width="300" height="168" class="alignnone size-medium wp-image-492" /></a>&nbsp;<a href="http://leejayxia.com/blog/wp-content/uploads/2009/03/00002960.png" rel="lightbox[486]"><img src="http://leejayxia.com/blog/wp-content/uploads/2009/03/00002960-300x168.png" alt="00002960" title="00002960" width="300" height="168" class="alignnone size-medium wp-image-495" /></a>&nbsp;<a href="http://leejayxia.com/blog/wp-content/uploads/2009/03/00002222.png" rel="lightbox[486]"><img src="http://leejayxia.com/blog/wp-content/uploads/2009/03/00002222-300x187.png" alt="00002222" title="00002222" width="300" height="187" class="alignnone size-medium wp-image-494" /></a>&nbsp;<a href="http://leejayxia.com/blog/wp-content/uploads/2009/03/00003649.png" rel="lightbox[486]"><img src="http://leejayxia.com/blog/wp-content/uploads/2009/03/00003649-300x187.png" alt="00003649" title="00003649" width="300" height="187" class="alignnone size-medium wp-image-496" /></a>&nbsp;<a href="http://leejayxia.com/blog/wp-content/uploads/2009/03/00005406.png" rel="lightbox[486]"><img src="http://leejayxia.com/blog/wp-content/uploads/2009/03/00005406-300x187.png" alt="00005406" title="00005406" width="300" height="187" class="alignnone size-medium wp-image-497" /></a>&nbsp;<a href="http://leejayxia.com/blog/wp-content/uploads/2009/03/fluid.png" rel="lightbox[486]"><img src="http://leejayxia.com/blog/wp-content/uploads/2009/03/fluid-300x187.png" alt="fluid" title="fluid" width="300" height="187" class="alignnone size-medium wp-image-498" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/perlin-noise-flow-field-and-smoky-ribbon/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Playing with fluid simulation</title>
		<link>http://leejayxia.com/blog/playing-with-fluid-simulation/</link>
		<comments>http://leejayxia.com/blog/playing-with-fluid-simulation/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 01:45:31 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[The Nature of Code]]></category>
		<category><![CDATA[fluid]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[Particle System]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[simulation]]></category>
		<category><![CDATA[Spring 2009]]></category>
		<category><![CDATA[Week4]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=482</guid>
		<description><![CDATA[As continuing playing with particle systems I came up this simple applet of fluid simuation app. Play applet at http://leejayxia.com/processing/noc_fluid or http://openprocessing.org/visuals/?visualID=1047.]]></description>
			<content:encoded><![CDATA[<p>As continuing playing with particle systems I came up this simple applet of fluid simuation app.</p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2009/02/noc_fluid.jpg" rel="lightbox[482]"><img src="http://leejayxia.com/blog/wp-content/uploads/2009/02/noc_fluid.jpg" alt="noc_fluid" title="noc_fluid" width="743" height="417" class="alignnone size-full wp-image-483" /></a></p>
<p>Play applet at <a href="http://leejayxia.com/processing/noc_fluid">http://leejayxia.com/processing/noc_fluid</a> or <a href="http://openprocessing.org/visuals/?visualID=1047">http://openprocessing.org/visuals/?visualID=1047</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/playing-with-fluid-simulation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Floating bubbles</title>
		<link>http://leejayxia.com/blog/floating-bubbles/</link>
		<comments>http://leejayxia.com/blog/floating-bubbles/#comments</comments>
		<pubDate>Sun, 22 Feb 2009 07:34:46 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[The Nature of Code]]></category>
		<category><![CDATA[bubble]]></category>
		<category><![CDATA[floating]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[nature of code]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[simulation]]></category>
		<category><![CDATA[Spring 2009]]></category>
		<category><![CDATA[Week2]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=463</guid>
		<description><![CDATA[Assignment 2 for Nature of Code. Trying to simulate floating effect by creating gravity and buoyancy under the imaginative surface of water (in this case, the middle of the screen).  This is a practice of simulating the second Newton&#8217;s law by applying acceleration to the particle&#8217;s velocity other than directly changing the velocity or location. Play [...]]]></description>
			<content:encoded><![CDATA[<p>Assignment 2 for <em>Nature of Code</em>. Trying to simulate floating effect by creating gravity and buoyancy under the imaginative surface of water (in this case, the middle of the screen). </p>
<p>This is a practice of simulating the second Newton&#8217;s law by applying acceleration to the particle&#8217;s velocity other than directly changing the velocity or location.</p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2009/02/noc_force.jpg" rel="lightbox[463]"><img class="alignnone size-medium wp-image-464" title="noc_force" src="http://leejayxia.com/blog/wp-content/uploads/2009/02/noc_force-198x300.jpg" alt="noc_force" width="198" height="300" /></a></p>
<p>Play applet at <a href="http://leejayxia.com/processing/noc_float/">http://leejayxia.com/processing/noc_float/</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/floating-bubbles/feed/</wfw:commentRss>
		<slash:comments>0</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>
	</channel>
</rss>

