<?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>formatlos &#187; Physical Computing</title>
	<atom:link href="http://blog.formatlos.de/category/physical-computing/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.formatlos.de</link>
	<description>Martin Rädlinger</description>
	<lastBuildDate>Tue, 30 Mar 2010 18:35:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Digital Graffiti &#8211; Spray Demo</title>
		<link>http://blog.formatlos.de/2008/12/19/digital-graffiti-spray-demo/</link>
		<comments>http://blog.formatlos.de/2008/12/19/digital-graffiti-spray-demo/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 15:20:49 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[RFID]]></category>

		<guid isPermaLink="false">http://blog.formatlos.de/?p=285</guid>
		<description><![CDATA[

The canvas with the van is not very nice, but just  [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.formatlos.de/2008/12/19/digital-graffiti-spray-demo/"><em>Click here to view the embedded video.</em></a></p>
<p>The canvas with the van is not very nice, but just to show you a demo of the spray can. sorry for my bad spraying skills. see a description of the project <a href="http://blog.formatlos.de/2008/12/01/digital-graffiti/">here</a>.
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.formatlos.de%2F2008%2F12%2F19%2Fdigital-graffiti-spray-demo%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.formatlos.de%2F2008%2F12%2F19%2Fdigital-graffiti-spray-demo%2F&amp;source=formatlos&amp;style=normal&amp;hashtags=ActionScript,AIR,Arduino,AS3,Physical+Computing,RFID" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.formatlos.de/2008/12/19/digital-graffiti-spray-demo/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Digital Spraycan &#8211; Demo</title>
		<link>http://blog.formatlos.de/2008/12/12/digital-spraycan-edemo/</link>
		<comments>http://blog.formatlos.de/2008/12/12/digital-spraycan-edemo/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 09:56:33 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[RFID]]></category>

		<guid isPermaLink="false">http://blog.formatlos.de/?p=273</guid>
		<description><![CDATA[

I did this demo video earlier this year while devel [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.formatlos.de/2008/12/12/digital-spraycan-edemo/"><em>Click here to view the embedded video.</em></a></p>
<p>I did this demo video earlier this year while developing the spray can for <a href="http://blog.formatlos.de/2008/12/01/digital-graffiti/">my thesis project</a>. The RGB LED wasn&#8217;t bright enough so I replaced it with a super bright one later on and moved it to the top of the can to lighten up the donut.
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.formatlos.de%2F2008%2F12%2F12%2Fdigital-spraycan-edemo%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.formatlos.de%2F2008%2F12%2F12%2Fdigital-spraycan-edemo%2F&amp;source=formatlos&amp;style=normal&amp;hashtags=Arduino,Physical+Computing,RFID" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.formatlos.de/2008/12/12/digital-spraycan-edemo/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using RFID in an ActionScript Application</title>
		<link>http://blog.formatlos.de/2008/12/09/using-rfid-in-an-actionscript-application/</link>
		<comments>http://blog.formatlos.de/2008/12/09/using-rfid-in-an-actionscript-application/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 12:57:29 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[RFID]]></category>

		<guid isPermaLink="false">http://blog.formatlos.de/?p=241</guid>
		<description><![CDATA[
 In order to receive tags, the RFID reader has to be  [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.formatlos.de/2008/12/09/using-rfid-in-an-actionscript-application/"><em>Click here to view the embedded video.</em></a></p>
<p> In order to receive tags, the RFID reader has to be activated through a click on the image. After that, the different RFID tags (sorry for my tiny tags) are used to create different forms.
</p>
<p><span id="more-241"></span></p>
<p style="margin-top:50px;">
The <a href="http://blog.formatlos.de/2008/12/08/arduino-id-12/">previous post</a> was all about wiring the RFID reader ID-12 and an Arduino board. Now I want to show you how to use this setup within an ActionScript application. </p>
<p>As you don&#8217;t have the possibility to access the hardware respectively the usb/bluetooth serial port directly, you have to use a Socket server which redirects the network socket connections to or from the serial ports. Fortunately there are already ready-to-use solutions like <a href="http://freshmeat.net/projects/serproxy/" target="_blank">serproxy</a> or TinkerProxy (<a href="http://tinker.it/now/wp-content/uploads/2007/06/tinkerproxy.zip">win</a>, <a href="http://tinker.it/now/wp-content/uploads/2007/05/tinkerproxy_mac.zip">osx</a>) available. Personally I prefer serproxy, but if you want to have a nice GUI I would recommend TinkerProxy.<br />
These proxy servers are not made specifically for the use with Flash and therefore they don&#8217;t implement a cross-domain-policy file. As you probably know this is needed for not getting a security error in your flash application. As a workaround for that problem you can get <a href="http://www.blog.lessrain.com/downloads/policyserver.jar" target="_blank">lessrains policyserver</a> and start it on port 5334 (java -jar policyserver.jar 5334). It will return an appropriate policy file when requested by the flash application.</p>
<p>
With these things in mind we can go for some code now.
</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">...
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">connect</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>_state <span style="color: #66cc66;">!</span>= DISCONNECTED<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">return</span>;
	_state = CONNECTING;
&nbsp;
	addSocketEvents<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">// load policy file from localhost, port 5334</span>
	Security.<span style="color: #006600;">loadPolicyFile</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;xmlsocket://&quot;</span> + SOCKET_HOST + <span style="color: #ff0000;">&quot;:&quot;</span> + <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span>POLICY_PORT<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #808080; font-style: italic;">// connect to proxy localhost, port 5333</span>
	_socket.<span style="color: #0066CC;">connect</span><span style="color: #66cc66;">&#40;</span>SOCKET_HOST, PROXY_PORT<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> disconnect<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>_state <span style="color: #66cc66;">!</span>= CONNECTED<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">return</span>;
	_state = DISCONNECTING;
&nbsp;
	sendDisconnect<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	processDisconnect<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> finalize<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	...
<span style="color: #66cc66;">&#125;</span>
...</pre></div></div>

<p>My RFID class implements basically 3 public methods + the EventDispatcher stuff.
</p>
<p style="margin-top:40px;">

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">...
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> connectSocket<span style="color: #66cc66;">&#40;</span>event : Event<span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span> 
<span style="color: #66cc66;">&#123;</span>   
	<span style="color: #808080; font-style: italic;">// send ping to arduino</span>
	_pingTimer = <span style="color: #000000; font-weight: bold;">new</span> Timer<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
	_pingTimer.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TimerEvent.<span style="color: #006600;">TIMER</span>, handleTimer<span style="color: #66cc66;">&#41;</span>;
	_pingTimer.<span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleTimer<span style="color: #66cc66;">&#40;</span>event : TimerEvent<span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	sendPing<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
...</pre></div></div>

<p>The Socket class dispatches Event.CONNECT when the connection to the proxy server is established but that doesn&#8217;t mean that the hardware is connected as well. To really know when the arduino is listening I use a timer to send a ping to the Arduino board. When I get the ping back, I know that the Arduino is ready to use.
</p>
<p style="margin-top:40px;">

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">...
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> processRfidTag<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	_cachePosition = _cache.<span style="color: #0066CC;">position</span> - <span style="color: #cc66cc;">1</span>;
	<span style="color: #000000; font-weight: bold;">var</span> bytesIn : <span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;
	<span style="color: #000000; font-weight: bold;">var</span> val : <span style="color: #0066CC;">int</span>;
	<span style="color: #000000; font-weight: bold;">var</span> rfidTag : <span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
&nbsp;
	<span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span>_cache.<span style="color: #006600;">bytesAvailable</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&amp;&amp;</span> bytesIn <span style="color: #66cc66;">&lt;</span> <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> 
	<span style="color: #66cc66;">&#123;</span>                        				
		val = _cache.<span style="color: #006600;">readByte</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">// if ETX or STX before the 10 digit reading -&gt; stop reading</span>
		<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>val == STX<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">||</span> <span style="color: #66cc66;">&#40;</span>val == ETX<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">break</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">// Do Ascii/Hex conversion:</span>
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>val <span style="color: #66cc66;">&gt;</span>= 0x30<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: #66cc66;">&#40;</span>val <span style="color: #66cc66;">&lt;</span> = 0x39<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> 
			val -= 0x30;
		<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>val <span style="color: #66cc66;">&gt;</span>= 0x41<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: #66cc66;">&#40;</span>val <span style="color: #66cc66;">&lt;</span> = 0x46<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
			val = <span style="color: #cc66cc;">10</span> + val - 0x41;
&nbsp;
		rfidTag += val.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">16</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">toUpperCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">// ready to read next digit</span>
		bytesIn++;                                
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">// read complete</span>
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>bytesIn == <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> 
	<span style="color: #66cc66;">&#123;</span> 
		<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>rfidTag <span style="color: #66cc66;">!</span>= <span style="color: #ff0000;">&quot;0000000000&quot;</span> <span style="color: #66cc66;">&#41;</span> _tag = rfidTag;
		<span style="color: #b1b100;">else</span> _tag = <span style="color: #000000; font-weight: bold;">null</span>;
&nbsp;
		_cachePosition = -<span style="color: #cc66cc;">1</span>;
		dispatchEvent<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> RFIDEvent<span style="color: #66cc66;">&#40;</span>RFIDEvent.<span style="color: #006600;">TAG_CHANGED</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
...</pre></div></div>

<p>When I receive some data from the socket, I look for the STX byte which is the header or marker of the RFID tag and get the tag via processRfidTag(). Beyond that I don&#8217;t read the bytes directly from the socket but write all the incoming data in a cache first to not loose any information coming in in different ProgressEvent.SOCKET_DATA events.
</pre>
</p>
<p>
<a href="http://blog.formatlos.de/wp-content/uploads/2008/12/id-12_demo.zip">Download the full source of my ID-12 demo</a> and don't forget to replace my tag ids with yours otherwise your RFID tags won't draw any form.
</p>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.formatlos.de%2F2008%2F12%2F09%2Fusing-rfid-in-an-actionscript-application%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.formatlos.de%2F2008%2F12%2F09%2Fusing-rfid-in-an-actionscript-application%2F&amp;source=formatlos&amp;style=normal&amp;hashtags=ActionScript,AIR,AS3,Flash,Physical+Computing,RFID" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.formatlos.de/2008/12/09/using-rfid-in-an-actionscript-application/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Arduino and the RFID reader ID-12</title>
		<link>http://blog.formatlos.de/2008/12/08/arduino-id-12/</link>
		<comments>http://blog.formatlos.de/2008/12/08/arduino-id-12/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 16:46:03 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[RFID]]></category>

		<guid isPermaLink="false">http://blog.formatlos.de/?p=216</guid>
		<description><![CDATA[This tutorial is all about wiring the RFID reader ID-12 [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial is all about wiring the <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=8419" target="_blank">RFID reader ID-12</a> and retrieving RFID tags via an Arduino board. There are already a few good tutorials with working code out there, but all of them are quite basic and therefore I want to show you how to use it in more complex applications. </p>
<p>There are basically 2 major differences in comparison to other implementations:</p>
<p style="margin-left: 30px;">
<strong>1. software serial</strong><br />
The ID-12 uses a serial connection to send the tags. All the other implementations are using the hardware serial pin (RX) to retrieve the information and send it to the computer. The problem of this setup with the ID-12 blocking the receive pin is that you can&#8217;t send any data from the computer to the arduino board anymore.  This implementation is using a software serial connection on an other I/O pin in order to maintain bidirectional communication.
</p>
<p style="margin-left: 30px;">
<strong>2. RFID tag removed</strong><br />
The ID-12 has no native method to determine whether a RFID tag is still in range or has been removed already. With a little workaround you can get this information as well.
</p>
<p>but enough talking, get this thing started:<br />
<span id="more-216"></span></p>
<h3>Wiring</h3>
<div class="image img-a" style="width:560px;"><img src="http://blog.formatlos.de/wp-content/uploads/2008/12/wiring_arduino_id-12.png" alt="" title="wiring"/></div>
<p>
Connect pin 11 to +5V, 1 and 7 to ground, 2 and 9 to Arduino pins 4 and 5;
</p>
<h3>Arduino code</h3>
<p>First of all you have to get the <a href="http://www.ladyada.net/make/eshield/AFSoftSerial.zip">AF_SoftSerial library</a> (you will need an Arduino board with an ATmega168) or <a href="http://arduiniana.org/libraries/NewSoftSerial/" target="_blank">NewSoftSerial</a> (for ATmega328). Uncompress and place it in the hardware/library directory under your Arduino software installation. </p>
<p>After installing the AFSoftSerial library you can <a href="http://blog.formatlos.de/wp-content/uploads/2008/12/id12.pde" target="_blank">download my arduino code</a> and upload it to your board. I don&#8217;t want to go through the code in detail, you can always leave a comment or get in touch with me if you have problems with it.
</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">...
<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>
  byte action <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> now <span style="color: #339933;">=</span> millis<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  updateID12<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// connection to computer established</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>connected <span style="color: #339933;">==</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    clearTag<span style="color: #009900;">&#40;</span>rfidTagTemp<span style="color: #339933;">,</span> <span style="color: #0000dd;">6</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// serial connection with rfid reader</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>rfidSerial.<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>
      <span style="color: #666666; font-style: italic;">// wait for the next STX byte</span>
      <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>rfidSerial.<span style="color: #202020;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> action <span style="color: #339933;">!=</span> <span style="color: #208080;">0x02</span><span style="color: #009900;">&#41;</span>
        action <span style="color: #339933;">=</span> rfidSerial.<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: #666666; font-style: italic;">// STX byte found -&gt; RFID tag available</span>
      <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>action <span style="color: #339933;">==</span> <span style="color: #208080;">0x02</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>readID12<span style="color: #009900;">&#40;</span>rfidTagTemp<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
          nowLastRfid <span style="color: #339933;">=</span> millis<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          rfidTagSeen <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span>
          updateCurrentRfidTag<span style="color: #009900;">&#40;</span>rfidTagTemp<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>rfidEnabled <span style="color: #339933;">&amp;&amp;</span> rfidTagSeen <span style="color: #339933;">==</span> <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>now <span style="color: #339933;">-</span> nowLastRfid<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;=</span> RFID_REMOVED_TIME<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>    
      rfidTagSeen <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
      updateCurrentRfidTag<span style="color: #009900;">&#40;</span>rfidTagTemp<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// serial connection with computer</span>
  <span style="color: #b1b100;">while</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: #339933;">&gt;</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> 
  <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// read action byte</span>
    action <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;">switch</span> <span style="color: #009900;">&#40;</span>action<span style="color: #009900;">&#41;</span> 
    <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;">// PING</span>
      <span style="color: #b1b100;">case</span> <span style="color: #208080;">0x01</span><span style="color: #339933;">:</span>
        Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x01</span><span style="color: #339933;">,</span> BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// (C)ONNECT</span>
      <span style="color: #b1b100;">case</span> <span style="color: #208080;">0x43</span><span style="color: #339933;">:</span>
        <span style="color: #666666; font-style: italic;">// clear serial</span>
        <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>rfidSerial.<span style="color: #202020;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> rfidSerial.<span style="color: #202020;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        connected <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// (D)ISCONNECT</span>
      <span style="color: #b1b100;">case</span> <span style="color: #208080;">0x44</span><span style="color: #339933;">:</span>
        connected <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// delay 100 milliseconds</span>
  delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
....</pre></div></div>

</p>
<p>
The first part of the code is for reading the RFID tags and checking if the tag is still in the range of the reader. <br /> <br />
The second part handles the communication with the computer. You can define specific bytes as marker and accordingly get the value of different sensors, execute functions on the hardware or whatever you want, e.g. in order to use the RFID reader and get an output of the RFID tags on your console you have to send the connect marker which is a &quot;C&quot; or 0&#215;43 in hex.
</p>
<h3>Update 08.02.2010 &#8211; Fix for the Atmega 328 chip </h3>
<p>Finally a fix for the Duemilanove (which is using an Atmega 328 chip). There is a new Sofware Serial Library out there which works with the Duemilanove, it&#8217;s called <a href="http://arduiniana.org/libraries/NewSoftSerial/" target="_blank">NewSoftSerial</a>. Just use this library instead of the old one and everything should work. Thanks <a href="http://www.thijseerens.com/" target="_blank">Thijs</a> for the information
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.formatlos.de%2F2008%2F12%2F08%2Farduino-id-12%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.formatlos.de%2F2008%2F12%2F08%2Farduino-id-12%2F&amp;source=formatlos&amp;style=normal&amp;hashtags=Arduino,Physical+Computing,RFID" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.formatlos.de/2008/12/08/arduino-id-12/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>Digital Graffiti &#8211; A Subculture Conquers Interactive Worlds</title>
		<link>http://blog.formatlos.de/2008/12/01/digital-graffiti/</link>
		<comments>http://blog.formatlos.de/2008/12/01/digital-graffiti/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 09:28:04 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[RFID]]></category>

		<guid isPermaLink="false">http://blog.formatlos.de/?p=185</guid>
		<description><![CDATA[Finally I delivered my thesis project I did in cooperat [...]]]></description>
			<content:encoded><![CDATA[<p>Finally I delivered my thesis project I did in cooperation with <a href="http://www.lessrain.com" target="_blank">Less Rain</a>. The subject was &raquo;Digital Graffiti &#8211; A Subculture Conquers Interactive Worlds&laquo; and it&#8217;s all about experimenting with different input devices for a physical, digital graffiti installation. The result is an Adobe AIR application using either the computer mouse, the Nintendo Wiimote or &raquo;VandalSpray&laquo; to paint digital canvases. VandalSpray is a digital spray can specifically designed for this purpose. It implements the attributes of a real spray can or at least trys to achieve them as natural as possible. Except a turnable bottom for changing the color, VandalSpray has no other interfacing elements than its real counterpart and therefore you don&#8217;t have to learn and explore the functionality first, because you intuitively know how to use it.</p>
<p>
<strong>VandalSpray features includes:</strong>
</p>
<ul>
<li>exchangeable caps</li>
<li>color display</li>
<li>digital valve system to vary the amount of &raquo;paint&laquo; coming out of the cap</li>
<li>different colors</li>
<li>wireless</li>
</ul>
<p>
The spray can is built upon the <a href="http://www.arduino.cc/" target="_blank">Arduino</a> platform and uses different sensors and electronic modules like a RFID reader, a super bright RGB LED, a Rotary Encoder, a Bluetooth module, a force sensitive resitor (FSR) and loads of wires and solder to implement the desired behavior. For tracking the spray can I use a Wiimote and the <a href="http://www.wiiflash.org" target="_blank">WiiFlash</a> ActionScript 3 library and server, but this could also be replaced by a standard webcam and an adequate tracking implementation.<br />
Because I didn&#8217;t want to put some kind of speaker in the spray can (there was no space left anyway) the spray sound is generated from the AIR app and output on the speakers of the notebook.
</p>
<p><div class="image img-a" style="width:560px;"><img src="http://blog.formatlos.de/wp-content/uploads/2008/12/vandalspray_1.jpg" alt="" title="VandalSpray vs. Montana spray can"/>
<p>VandalSpray vs. Montana spray can</p>
</div>
<div class="image img-a" style="width:560px;"><img src="http://blog.formatlos.de/wp-content/uploads/2008/12/vandalspray_2.jpg" alt="" title="VandalSpray electronics"/>
<p>VandalSpray electronics</p>
</div>
<p><strong>More</strong><br />
<a href="http://blog.formatlos.de/2008/12/12/digital-spraycan-edemo/">http://blog.formatlos.de/2008/12/12/digital-spraycan-edemo/</a><br />
<a href="http://blog.formatlos.de/2008/12/19/digital-graffiti-spray-demo/">http://blog.formatlos.de/2008/12/19/digital-graffiti-spray-demo/</a></p>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.formatlos.de%2F2008%2F12%2F01%2Fdigital-graffiti%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.formatlos.de%2F2008%2F12%2F01%2Fdigital-graffiti%2F&amp;source=formatlos&amp;style=normal&amp;hashtags=ActionScript,AIR,Arduino,AS3,Physical+Computing,RFID" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.formatlos.de/2008/12/01/digital-graffiti/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Physical Computing</title>
		<link>http://blog.formatlos.de/2008/06/18/physical-computing/</link>
		<comments>http://blog.formatlos.de/2008/06/18/physical-computing/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 09:51:29 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Physical Computing]]></category>

		<guid isPermaLink="false">http://blog.formatlos.de/?p=18</guid>
		<description><![CDATA[In times of multitouch tables and the wii alternative n [...]]]></description>
			<content:encoded><![CDATA[<p>In times of multitouch tables and the wii alternative navigaton methods and interfaces are getting more and more attractive. Therefore I wanted to provide a few links to help those who are not very familiar with electronics but can&#8217;t keep their hands off playing with hardware stuff (like me). In the end it&#8217;s a very good feeling to connect your poorly soldered stuff to the computer to get some outputs on the screen, always hoping not to destroy the expensive electronical components or even worse the whole flat.</p>
<p>First of all you should get an easy-to-use prototyping platform like arduino (<a href="http://arduino.cc/" target="_blank">http://arduino.cc/</a>), wiring (<a href="http://wiring.org.co" target="_blank">http://wiring.org.co</a>), freeduino (<a href="http://www.freeduino.org/" target="_blank">http://www.freeduino.org/</a>) &#8230; the arduino board is not very expensive and there are a lot of tutorials how to use it and how to connect other hardware to it.</p>
<p><strong>getting started with electronics and arduino:</strong></p>
<ul>
<li><span class="topsubheadertext"><a href="http://www.ladyada.net/learn/arduino/" target="_blank">Learn Electronics using Arduino (http://www.ladyada.net/learn/arduino/)<br />
</a></span></li>
<li><a href="http://www.physical-computing.de/" target="_blank"><span class="topsubheadertext">Tutorials in german (</span><span class="topsubheadertext">http://www.physical-computing.de/</span></a><span class="topsubheadertext"><a href="http://www.physical-computing.de/" target="_blank">)</a></span></li>
<li><a href="http://protolab.pbwiki.com/" target="_blank"><span class="topsubheadertext">Tutorials </span>by the Stanford HCI Group (http://protolab.pbwiki.com/)</a></li>
<li><a href="http://itp.nyu.edu/physcomp/">ITP Physical Computing (http://itp.nyu.edu/physcomp/)</a></li>
<li><a href="http://www.tigoe.net/pcomp/" target="_blank">Tom Igoe (http://www.tigoe.net/pcomp/)</a></li>
</ul>
<p>another good source of inspiration is flickr. just search for <a href="http://www.flickr.com/search/?q=arduino&amp;w=all" target="_blank">»arduino«</a> and you&#8217;ll find a lot of cool projects, links and working circuits.
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.formatlos.de%2F2008%2F06%2F18%2Fphysical-computing%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.formatlos.de%2F2008%2F06%2F18%2Fphysical-computing%2F&amp;source=formatlos&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.formatlos.de/2008/06/18/physical-computing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
