<?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>Evil Quark Labs</title>
	<atom:link href="http://evilquark.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://evilquark.com/blog</link>
	<description>Figuring Stuff Out</description>
	<lastBuildDate>Thu, 24 Sep 2009 03:44:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A Processing Java Applet in WordPress</title>
		<link>http://evilquark.com/blog/?p=84</link>
		<comments>http://evilquark.com/blog/?p=84#comments</comments>
		<pubDate>Wed, 23 Sep 2009 22:02:09 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Applet]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://evilquark.com/blog/?p=84</guid>
		<description><![CDATA[Turns out that figuring out how to embed a Processing Java applet in WordPress was quite the endeavor.   Ended up writing a Wordpress plugin.  Here is a link to the tarball: wp-proc-embed.tar.gz
A few brief instructions for installation and use:

Extract into the wp-content/plugins directory (Same as every other plugin for WordPress).  If you can&#8217;t figure [...]]]></description>
			<content:encoded><![CDATA[<p>Turns out that figuring out how to embed a Processing Java applet in WordPress was quite the endeavor.   Ended up writing a Wordpress plugin.  Here is a link to the tarball: <a href="../downloads/wp-proc-embed.tar.gz">wp-proc-embed.tar.gz</a></p>
<p>A few brief instructions for installation and use:</p>
<ol>
<li>Extract into the wp-content/plugins directory (Same as every other plugin for WordPress).  If you can&#8217;t figure out how to extract a .tar.gz file, and I&#8217;m in a good mood, let me know and I&#8217;ll create a zip for you.</li>
<li>Login to wordpress as admin and activate the plugin.</li>
<li>Export your Processing project.</li>
<li>Copy/scp/ftp the entire directory tree of the sketch (which should now include an applet directory) to wp-content/plugins/wp-proc-embed/</li>
<li>As an example of what the directory structure should look like in step 4 I have included the applet &#8220;threeballsclass&#8221;.  The exported java files appear in wp-content/plugins/wp-proc-embed/threeballsclass/applet/</li>
<li>Make a new post and include the following tag to display the threeballsclass applet with a dimension of 200 x 200:   LEFT BRACKET processing=threeballsclass 200 200 RIGHT BRACKET</li>
<li>Publish and Pray.</li>
<li>I just realized that I called the example project &#8220;threeballsclass&#8221; and there are actually four balls flying around.  Deal with it.</li>
</ol>
<p>Here&#8217;s the applet in action:</p>
<p><div id="processing">
                           <!--[if !IE]> -->
                                <object classid="java:threeballsclass.class" 
                                type="application/x-java-applet"
                                archive="wp-content/plugins/wp-proc-embed/threeballsclass/applet/threeballsclass.jar"
                                width="200" height="200"
                                standby="Loading Processing software..." >
                                        <param name="archive" value="wp-content/plugins/wp-proc-embed/threeballsclass/applet/threeballsclass.jar" />
                                        <param name="mayscript" value="true" />
                                        <param name="scriptable" value="true" />
                                        <param name="image" value="loading.gif" />
                                        <param name="boxmessage" value="Loading Processing software..." />
                                        <param name="boxbgcolor" value="#FFFFFF" />
                                        <param name="test_string" value="outer" />
                        <!--<![endif]-->
                                
                                <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" 
                                                codebase="http://java.sun.com/update/1.4.2/jinstall-1_4_2_12-windows-i586.cab"
                                                width="200" height="200"
                                                standby="Loading Processing software..."  >
                                        <param name="code" value="threeballsclass" />
                                        <param name="archive" value="wp-content/plugins/wp-proc-embed/threeballsclass/applet/threeballsclass.jar" />
                                        <param name="mayscript" value="true" />
                                        <param name="scriptable" value="true" />
                                        <param name="image" value="loading.gif" />
                                        <param name="boxmessage" value="Loading Processing software..." />
                                        <param name="boxbgcolor" value="#FFFFFF" />
                                        <param name="test_string" value="inner" />
                                        <p>
                                                        This browser does not have a Java Plug-in.
                                                        <br />
                                                        <a href="http://java.sun.com/products/plugin/downloads/index.html" title="Download Java Plug-in">


	 
                                                                Get the latest Java Plug-in here.
                                                        </a>
                                        </p>
                                </object>
                        <!--[if !IE]> -->
                                </object>
                        <!--<![endif]-->
                        </div></p>
<p>(If anyone knows the escape character for the left and right brackets, so I don&#8217;t have to use LEFT BRACKET and RIGHT BRACKET above, let me know.  I&#8217;m having to do this because otherwise it displays the applet)</p>
]]></content:encoded>
			<wfw:commentRss>http://evilquark.com/blog/?feed=rss2&amp;p=84</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Ohm meter using a Voltage Divider</title>
		<link>http://evilquark.com/blog/?p=49</link>
		<comments>http://evilquark.com/blog/?p=49#comments</comments>
		<pubDate>Tue, 22 Sep 2009 03:57:20 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Circuits]]></category>

		<guid isPermaLink="false">http://evilquark.com/blog/?p=49</guid>
		<description><![CDATA[Nothing too fancy this time around, just a simple project that calculates the resistance of a resistor.  The circuit is based on a simple voltage divider.  First, a wire is connected from the 5V pin on the Arduino to the breadboard +5V bus.  Then, another wire connects the Gnd pin on the Arduino to the [...]]]></description>
			<content:encoded><![CDATA[<p>Nothing too fancy this time around, just a simple project that calculates the resistance of a resistor.  The circuit is based on a simple voltage divider.  First, a wire is connected from the 5V pin on the Arduino to the breadboard +5V bus.  Then, another wire connects the Gnd pin on the Arduino to the GND bus on the breadboard.  Now that you have power, put two resistors in series.  One should be your &#8220;known&#8221; resistance; I used a 10 kohm resistor for this.  The other is the &#8220;unknown&#8221; resistor that we are trying to find the resistance of.  In between these two resistors, another wire should be connected to one of the analogue pins on the Arduino (I used pin 0).  Below are two pictures which show the setup.</p>
<p><img class="size-medium wp-image-50 alignnone" title="res1" src="http://evilquark.com/blog/wp-content/uploads/res1-300x225.jpg" alt="res1" width="300" height="225" /> <img class="size-medium wp-image-51 alignnone" title="res2" src="http://evilquark.com/blog/wp-content/uploads/res2-300x225.jpg" alt="res2" width="300" height="225" /></p>
<p>Here is the Arduino code which calculates the unknown resistance, and outputs it to serial:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">int</span> aPinIn <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>            <span style="color: #666666; font-style: italic;">// Analogue Input on Arduino</span>
<span style="color: #993333;">int</span> val <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>               <span style="color: #666666; font-style: italic;">// The raw analogue value</span>
<span style="color: #993333;">float</span> Vout <span style="color: #339933;">=</span> <span style="color:#800080;">0.0</span><span style="color: #339933;">;</span>          <span style="color: #666666; font-style: italic;">// Voltage at point between resistors</span>
                           <span style="color: #666666; font-style: italic;">// (relative to ground)</span>
<span style="color: #993333;">float</span> Vin <span style="color: #339933;">=</span> <span style="color:#800080;">5.0</span><span style="color: #339933;">;</span>           <span style="color: #666666; font-style: italic;">// Vcc (5 Volts)</span>
<span style="color: #993333;">float</span> Rknown <span style="color: #339933;">=</span> <span style="color:#800080;">10000.0</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// The known resistor (10 kohms)</span>
<span style="color: #993333;">float</span> Runknown <span style="color: #339933;">=</span> <span style="color:#800080;">0.0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
  Serial.<span style="color: #202020;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">13</span><span style="color: #339933;">,</span> HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
  val <span style="color: #339933;">=</span> analogRead<span style="color: #009900;">&#40;</span>aPinIn<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>              <span style="color: #666666; font-style: italic;">// Read in val (0-1023)</span>
  Vout <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Vin<span style="color: #339933;">/</span><span style="color:#800080;">1024.0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #993333;">float</span><span style="color: #009900;">&#40;</span>val<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>      <span style="color: #666666; font-style: italic;">// Convert to voltage</span>
  Runknown <span style="color: #339933;">=</span> Rknown<span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>Vin<span style="color: #339933;">/</span>Vout<span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// Calculate Runknown</span>
&nbsp;
  Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Vout: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span>Vout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>                  <span style="color: #666666; font-style: italic;">// Output everything</span>
  Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;R: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span>Runknown<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>                           <span style="color: #666666; font-style: italic;">// delay for readability</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Here is the serial output (updating every second):</p>
<p><img class="size-full wp-image-60 alignnone" title="res_pic" src="http://evilquark.com/blog/wp-content/uploads/res_pic1.png" alt="res_pic" width="634" height="410" /><br />
Not bad.  According to the color code, the unknown is a 330 Ohm resistor with 5% tolerance.  The circuit/code produces a value of 333.</p>
]]></content:encoded>
			<wfw:commentRss>http://evilquark.com/blog/?feed=rss2&amp;p=49</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Wireless with XBee</title>
		<link>http://evilquark.com/blog/?p=28</link>
		<comments>http://evilquark.com/blog/?p=28#comments</comments>
		<pubDate>Fri, 18 Sep 2009 14:16:03 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Protocol]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Wireless]]></category>
		<category><![CDATA[XBee]]></category>
		<category><![CDATA[XBee Explorer USB]]></category>

		<guid isPermaLink="false">http://evilquark.com/blog/?p=28</guid>
		<description><![CDATA[Have you ever had one of those projects where, after spending hours preparing and reading up on background material, find yourself ultimately baffled as to why it is not working?  That&#8217;s what happened here, and as it turned out, the solution was trivial in the form of a single line of Processing code.  [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever had one of those projects where, after spending hours preparing and reading up on background material, find yourself ultimately baffled as to why it is not working?  That&#8217;s what happened here, and as it turned out, the solution was trivial in the form of a single line of Processing code.  We&#8217;ll get to that later.  The goal here was to get two Digi XBee RF modules to communicate over 802.15.4, in particular, a simple &#8220;Hello World&#8221; type of event in the form of a blinking LED.</p>
<p>Alright, here&#8217;s how it work.  The first XBee is connected to an XBee Explorer from Sparkfun.  This board is awesome because it takes care of the conversion of serial signals to USB.  Furthermore it has LEDs which indicate when the XBee is receiving or transmitting data.  Here is a picture of the Explorer itself, and my Explorer mounted with an Xbee and connected to the iMac via a mini-USB cable:</p>
<p><img class="alignnone size-medium wp-image-29" title="xbee_explorer" src="http://evilquark.com/blog/wp-content/uploads/xbee_explorer-300x300.jpg" alt="xbee_explorer" width="300" height="300" /><img class="alignnone size-medium wp-image-30" title="xbee1" src="http://evilquark.com/blog/wp-content/uploads/xbee1-300x225.jpg" alt="xbee1" width="300" height="225" /></p>
<p>The Processing code for sending out bytes of data through the XBee and over the wireless is very similar to the code from the previous post:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">import processing.<span style="color: #202020;">serial</span>.<span style="color: #339933;">*;</span>
&nbsp;
Serial myPort<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  println<span style="color: #009900;">&#40;</span>Serial.<span style="color: #202020;">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>
  myPort <span style="color: #339933;">=</span> new Serial<span style="color: #009900;">&#40;</span>this<span style="color: #339933;">,</span> Serial.<span style="color: #202020;">list</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> draw<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
myPort.<span style="color: #202020;">write</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'x'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
myPort.<span style="color: #202020;">write</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'o'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The second XBee (receiving XBee) is connected to a breakout board (from Sparkfun) which allows the XBee which has 2mm pin spacing to be used on breadboards which commonly have holes compatible with .1&#8243; pin spacing.  Four wires are connecting the XBee to the Arduino (see picture below).  The yellow wire provides 3.3 volts from the aptly named pin on the Arduino.  The red and green wires connect the XBee&#8217;s DIN and DOUT, to the Arduino&#8217;s TX and RX pins, respectively.  Finally, the black wire is connected to the ground pin of the Arduino.  Technically, the voltage of the DIN and DOUT connections should be translated down to 3.3 volts, but actually works fine at 5 volts (The unit MUST be powered at 3.3 volts, however).</p>
<p><img class="size-medium wp-image-34 alignnone" title="xbee2" src="http://evilquark.com/blog/wp-content/uploads/xbee2-300x225.jpg" alt="xbee2" width="300" height="225" /></p>
<p>After about the 5th try, I was able to snap a picture that actually had the blinking LED in an ON state.  The code that was loaded onto the Arduino was:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  Serial.<span style="color: #202020;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">13</span><span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>Serial.<span style="color: #202020;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
    byte val <span style="color: #339933;">=</span> Serial.<span style="color: #202020;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>val <span style="color: #339933;">==</span> <span style="color: #ff0000;">'x'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> digitalWrite<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">13</span><span style="color: #339933;">,</span> HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>val <span style="color: #339933;">==</span> <span style="color: #ff0000;">'o'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> digitalWrite<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">13</span><span style="color: #339933;">,</span> LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>There you have it, a proof-of-concept that wireless communication is possible using these XBee modules.  Oh yeah, the trivial problem that I alluded to in the beginning of this post was that in the Processing code for the transmitting XBee, I had a loop() function instead of a draw() function.  Yeah, don&#8217;t do that.  Ok, here&#8217;s video proof that the LED is actually blinking, and that this whole thing isn&#8217;t a farce:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="350" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/L3ekisA3op8" /><embed type="application/x-shockwave-flash" width="425" height="350" src="http://www.youtube.com/v/L3ekisA3op8"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://evilquark.com/blog/?feed=rss2&amp;p=28</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enabling Serial Communication in Processing/Arduino</title>
		<link>http://evilquark.com/blog/?p=4</link>
		<comments>http://evilquark.com/blog/?p=4#comments</comments>
		<pubDate>Thu, 17 Sep 2009 16:10:02 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Protocol]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Serial Communication]]></category>

		<guid isPermaLink="false">http://evilquark.com/blog/?p=4</guid>
		<description><![CDATA[I have been trying to dissect the differences between the implementation of serial asynchronous communication in Processing 1.0 and the Arduino IDE.  There are even broader differences between the two environments (Arduino is based on C/C++, and Processing is Java based) but fortunately these do not come into play with the current investigation.  Arduino is [...]]]></description>
			<content:encoded><![CDATA[<p>I have been trying to dissect the differences between the implementation of serial asynchronous communication in Processing 1.0 and the Arduino IDE.  There are even broader differences between the two environments (Arduino is based on C/C++, and Processing is Java based) but fortunately these do not come into play with the current investigation.  Arduino is a simple development environment which allows for the programming of Arduino boards.  The board I am currently using is the Duemilanove (Italian for 2009), which has at its heart an ATmega.328 micro-controller.</p>
<p style="text-align: center;"><img class="aligncenter" title="Duemilanove" src="http://www.fektasm.com/wp-content/uploads/2009/05/arduinoduemilanove.jpg" alt="" width="200" height="200" /></p>
<p>Processing is a programming language that allows users to quickly create programs, or &#8220;sketches&#8221;,  that generate graphics and gives control to input and output devices such as the keyboard, mouse, and serial ports.   More information on Processing can be found <a href="http://www.processing.org" target="_blank">here.</a> What follows is how to enable serial communication for both the Arduino IDE and Processing.</p>
<p>The first issue is choosing which serial port to use in the current project.  In the Arduino IDE, this is accomplished by selecting Tools &#8212; Serial Port and then choosing the appropriate serial port.</p>
<p style="text-align: center;"><img class="size-medium wp-image-7 aligncenter" title="Selecting the Serial Port in Arduino" src="http://evilquark.com/blog/wp-content/uploads/Serial_Port1-250x300.gif" alt="Selecting the Serial Port in Arduino" width="250" height="300" /></p>
<p>Note that in the above figure, that Serial Port is not available (grey).  If you have successfully installed the serial drivers, then you should get a list of available ports (I&#8217;m not writing this entry from my development machine).  Selecting your serial port in the Arduino is as easy as that.  Processing, however, is a much broader programming environment and therefore hooking up to a serial port must be done manually.  The following code shows how to do this:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Serial communication in Processing 1.0</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Import the processing serial libraries</span>
import processing.<span style="color: #202020;">serial</span>.<span style="color: #339933;">*;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Declare a serial port:</span>
Serial myPort<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// List all available serial ports:</span>
println<span style="color: #009900;">&#40;</span>Serial.<span style="color: #202020;">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>
&nbsp;
<span style="color: #808080; font-style: italic;">/*
Open whatever port is the one you're using.  Mine is zero,
hence Serial.list()[0].  Also, 9600 is the bps (bits per second) of
the connection.
*/</span>
&nbsp;
myPort <span style="color: #339933;">=</span> new Serial<span style="color: #009900;">&#40;</span>this<span style="color: #339933;">,</span> Serial.<span style="color: #202020;">list</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</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;">// Send an E to the serial port.  69 is the ASCII value for capital E.</span>
myPort.<span style="color: #202020;">write</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">69</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I would imagine that something similar to the above block of code is actually running when selecting the serial port from the drop-down menu in the case of the Arduino IDE.  Also worth mentioning is that when using the Arduino IDE, the serial libraries have already been included, and therefore do not have to included manually as was the case with Processing.</p>
]]></content:encoded>
			<wfw:commentRss>http://evilquark.com/blog/?feed=rss2&amp;p=4</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Evil Quark Blog has Returned!</title>
		<link>http://evilquark.com/blog/?p=3</link>
		<comments>http://evilquark.com/blog/?p=3#comments</comments>
		<pubDate>Wed, 16 Sep 2009 19:00:06 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://evilquark.com/blog/?p=3</guid>
		<description><![CDATA[The blog portion of the website has returned.  Make sure and check back to see what&#8217;s going on in the Evil Quark Labs.
]]></description>
			<content:encoded><![CDATA[<p>The blog portion of the website has returned.  Make sure and check back to see what&#8217;s going on in the Evil Quark Labs.</p>
]]></content:encoded>
			<wfw:commentRss>http://evilquark.com/blog/?feed=rss2&amp;p=3</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

