<?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>silentlyCrashing::net &#187; physcomp</title>
	<atom:link href="http://www.silentlycrashing.net/blog/tag/physcomp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.silentlycrashing.net/blog</link>
	<description>animation and code</description>
	<lastBuildDate>Sun, 23 May 2010 14:02:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.2</generator>
		<item>
		<title>Forget-Me-Not</title>
		<link>http://www.silentlycrashing.net/blog/2008/12/14/forget-me-not/</link>
		<comments>http://www.silentlycrashing.net/blog/2008/12/14/forget-me-not/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 15:46:46 +0000</pubDate>
		<dc:creator>ez</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[physcomp]]></category>

		<guid isPermaLink="false">http://www.silentlycrashing.net/blog/?p=273</guid>
		<description><![CDATA[Forget-Me-Not is a system of small devices you can use to make sure you never leave anything of yours behind again. Just attach one of the smaller units to an item you are prone to forgetting, like your keys or your umbrella, and keep the larger unit in an item you are likely not to [...]]]></description>
			<content:encoded><![CDATA[<p>Forget-Me-Not is a system of small devices you can use to make sure you never leave anything of yours behind again.</p>
<p><a class="tt-flickr tt-flickr-Medium" title="xbee 019" href="http://www.flickr.com/photos/prisonerjohn/3106834607/"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3192/3106834607_b0a65ffbac.jpg" alt="xbee 019" width="500" height="375" /></a></p>
<p>Just attach one of the smaller units to an item you are prone to forgetting, like your keys or your umbrella, and keep the larger unit in an item you are likely not to forget, like your bag. If they ever get separated, your bag will scream out at you to remind you to go find your keys.</p>
<p><a class="tt-flickr tt-flickr-Medium" title="xbee 013" href="http://www.flickr.com/photos/prisonerjohn/3107665434/"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3172/3107665434_db520e1c9e.jpg" alt="xbee 013" width="500" height="375" /></a></p>
<p><span id="more-273"></span><br />
The system works using <a href="http://www.digi.com/products/wireless/point-multipoint/xbee-series1-module.jsp">XBee</a> wireless radios. Each small unit pings the base constantly, which analyzes the incoming packet to parse out the address and signal strength of each message. If any of the units has a signal strength lower than a certain threshold, a trigger signal is sent to a hacked <a href="http://www.electronics123.com/s.nl/it.A/id.1915/.f">sound module</a>, which plays the appropriate sound for the missing device.</p>

<div class="wp_codebox"><table><tr id="p2732"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
</pre></td><td class="code" id="p273code2"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//----------------------------</span>
<span style="color: #666666; font-style: italic;">// Forget-Me-Not</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// by Elie Zananiri &amp; HyeJin Yoo</span>
<span style="color: #666666; font-style: italic;">// based on code from Making Things Talk by Tom Igoe</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//----------------------------</span>
#define SOUND1    <span style="color: #cc66cc;">4</span>
#define SOUND2    <span style="color: #cc66cc;">5</span>
#define SOUND3    <span style="color: #cc66cc;">6</span>
&nbsp;
#define MONITOR   <span style="color: #cc66cc;">13</span>
&nbsp;
#define THRESHOLD <span style="color: #cc66cc;">79</span>
#define MSGLENGTH <span style="color: #cc66cc;">22</span>
#define INTERVAL  <span style="color: #cc66cc;">30000</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//----------------------------</span>
<span style="color: #000066; font-weight: bold;">int</span> packet<span style="color: #009900;">&#91;</span>MSGLENGTH<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> byteCounter<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">long</span> lastPlayedSound1 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">long</span> lastPlayedSound2 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">long</span> lastPlayedSound3 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">int</span> address <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> rssi <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//----------------------------</span>
<span style="color: #000066; font-weight: bold;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// open the serial port</span>
  Serial.<span style="color: #006633;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// configure output pins</span>
  pinMode<span style="color: #009900;">&#40;</span>SOUND1, OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>SOUND2, OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>SOUND3, OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//----------------------------</span>
<span style="color: #000066; font-weight: bold;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// check for any messages and read up to 2 packets at a time</span>
  <span style="color: #000066; font-weight: bold;">int</span> readCount <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>Serial.<span style="color: #006633;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">&amp;&amp;</span> readCount <span style="color: #339933;">&lt;</span> <span style="color: #009900;">&#40;</span>MSGLENGTH<span style="color: #339933;">*</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    handleIncoming<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    readCount<span style="color: #339933;">++;</span>
    delay<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// flash the monitor pin to let us know all is working</span>
  digitalWrite<span style="color: #009900;">&#40;</span>MONITOR, HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  delay<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>MONITOR, LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  delay<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//----------------------------</span>
<span style="color: #000066; font-weight: bold;">void</span> handleIncoming<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// read a byte from the port</span>
  <span style="color: #000066; font-weight: bold;">int</span> b <span style="color: #339933;">=</span> Serial.<span style="color: #006633;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// if this is a start byte, it's a new packet</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>b <span style="color: #339933;">==</span> 0x7E<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// if there is data, parse the previous packet</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>packet<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      parseData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// reset the byte counter</span>
    byteCounter <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// store the current byte into the packet</span>
  packet<span style="color: #009900;">&#91;</span>byteCounter<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> b<span style="color: #339933;">;</span>
  byteCounter<span style="color: #339933;">++;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//----------------------------</span>
<span style="color: #000066; font-weight: bold;">void</span> parseData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// read the address, which is a two-byte value</span>
  address <span style="color: #339933;">=</span> packet<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> packet<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">256</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// read the signal strength</span>
  rssi <span style="color: #339933;">=</span> packet<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// get the time</span>
  <span style="color: #000066; font-weight: bold;">long</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;
  <span style="color: #666666; font-style: italic;">// trigger a sound if the signal is not strong enough</span>
  <span style="color: #666666; font-style: italic;">// and the sound has not played in a while</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>address <span style="color: #339933;">==</span> 0x1ABC <span style="color: #339933;">&amp;&amp;</span> rssi <span style="color: #339933;">&gt;</span> THRESHOLD<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>now <span style="color: #339933;">-</span> lastPlayedSound1 <span style="color: #339933;">&gt;</span> INTERVAL<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      lastPlayedSound1 <span style="color: #339933;">=</span> now<span style="color: #339933;">;</span>
      playSound<span style="color: #009900;">&#40;</span>SOUND1<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: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>address <span style="color: #339933;">==</span> 0x1CBA <span style="color: #339933;">&amp;&amp;</span> rssi <span style="color: #339933;">&gt;</span> THRESHOLD<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>now <span style="color: #339933;">-</span> lastPlayedSound2 <span style="color: #339933;">&gt;</span> INTERVAL<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      lastPlayedSound2 <span style="color: #339933;">=</span> now<span style="color: #339933;">;</span>
      playSound<span style="color: #009900;">&#40;</span>SOUND2<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: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>address <span style="color: #339933;">==</span> 0x1BBB <span style="color: #339933;">&amp;&amp;</span> rssi <span style="color: #339933;">&gt;</span> THRESHOLD<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>now <span style="color: #339933;">-</span> lastPlayedSound3 <span style="color: #339933;">&gt;</span> INTERVAL<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     lastPlayedSound3 <span style="color: #339933;">=</span> now<span style="color: #339933;">;</span>
     playSound<span style="color: #009900;">&#40;</span>SOUND3<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>
&nbsp;
<span style="color: #666666; font-style: italic;">//----------------------------</span>
<span style="color: #000066; font-weight: bold;">void</span> playSound<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> sound<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>sound, HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  delay<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>sound, LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  delay<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">6</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// enough time to play the entire sample</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// flush the serial buffer to ignore all backed up messages</span>
  Serial.<span style="color: #006633;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The project is still a prototype at this stage and many improvements could still be made. For one, the smaller modules should be as small as possible and should be equipped with rings or clips so that they can be easily attached to objects. The base module should also be more compact and the audio circuit should be cleaned up because it currently does not sound very good.</p>
<p><a class="tt-flickr tt-flickr-Medium" title="xbee 002" href="http://www.flickr.com/photos/prisonerjohn/3106831415/"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3003/3106831415_5a48a48a8f.jpg" alt="xbee 002" width="500" height="375" /></a>¬†</p>
<p>One suggestion we got during our presentation was to try switching over to Bluetooth signals. This would allow us to use a cell phone as the base module, which is compact and already has good audio recording and playback ability. Also, using a phone would allow us to create a graphical piece of software to add more units to the system and to customize the behaviour for each one (which sample to play, how far the object should be to trigger the sound, etc.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.silentlycrashing.net/blog/2008/12/14/forget-me-not/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tapper (sorta) finished</title>
		<link>http://www.silentlycrashing.net/blog/2008/10/22/tapper-sorta-finished/</link>
		<comments>http://www.silentlycrashing.net/blog/2008/10/22/tapper-sorta-finished/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 17:59:02 +0000</pubDate>
		<dc:creator>ez</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[physcomp]]></category>

		<guid isPermaLink="false">http://www.silentlycrashing.net/blog/?p=222</guid>
		<description><![CDATA[We finished working on the Tapper gloves, and although there is still aesthetic work to be done, this version is complete functionality-wise. Tapper now outputs a MIDI signal instead of the custom protocol we were previously using. This means that it won&#8217;t work anymore with the Processing sequencer we had built, but that it works [...]]]></description>
			<content:encoded><![CDATA[<p>We finished working on the Tapper gloves, and although there is still aesthetic work to be done, this version is complete functionality-wise.</p>
<p><a class="tt-flickr tt-flickr-Small" title="P1040075" href="http://www.flickr.com/photos/prisonerjohn/2963641146/"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3039/2963641146_da9cb26b2c_m.jpg" alt="P1040075" width="240" height="135" /></a> <a class="tt-flickr tt-flickr-Small" title="P1040068" href="http://www.flickr.com/photos/prisonerjohn/2962795677/"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3151/2962795677_63acfcd203_m.jpg" alt="P1040068" width="240" height="135" /></a></p>
<p>Tapper now outputs a <a href="http://en.wikipedia.org/wiki/MIDI">MIDI</a> signal instead of the custom protocol we were previously using. This means that it won&#8217;t work anymore with the Processing sequencer we had built, but that it works with most audio production apps available, such as <a href="http://www.ableton.com/live">Live</a>, <a href="http://www.apple.com/ilife/garageband/">GarageBand</a>, or <a href="http://www.propellerheads.se/products/reason/">Reason</a>. Tapper sends a NOTE ON signal when an FSR is pressed, an AFTERTOUCH as long as the FSR is still pressed, and a NOTE OFF when the FSR is released. This makes the response much more natural as we don&#8217;t get repeated notes when the FSR remains pressed and we can change the velocity of a note by pressing harder or softer.</p>
<p><a href="http://www.silentlycrashing.net/blog/2008/10/22/tapper-sorta-finished/"><em>Click here to view the embedded video.</em></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.silentlycrashing.net/blog/2008/10/22/tapper-sorta-finished/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tapper prototype</title>
		<link>http://www.silentlycrashing.net/blog/2008/10/15/tapper-prototype/</link>
		<comments>http://www.silentlycrashing.net/blog/2008/10/15/tapper-prototype/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 18:37:46 +0000</pubDate>
		<dc:creator>ez</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[physcomp]]></category>

		<guid isPermaLink="false">http://www.silentlycrashing.net/blog/?p=215</guid>
		<description><![CDATA[Ari and I advanced our work from¬†phase 1¬†to phase 2 of the Tapper gloves by conquering the aspect of the project that proved to be our most serious roadblock: actually integrating the technology into the apparel. No, it wasn‚Äôt the programming or the circuitry that threw us for a loop‚Ä¶ it was dealing with unwieldy [...]]]></description>
			<content:encoded><![CDATA[<p>Ari and I advanced our work from¬†<a href="http://www.silentlycrashing.net/blog/2008/10/07/tapper-proposal/">phase 1</a>¬†to phase 2 of the Tapper gloves by conquering the aspect of the project that proved to be our most serious roadblock: actually integrating the technology into the apparel. No, it wasn‚Äôt the programming or the circuitry that threw us for a loop‚Ä¶ it was dealing with unwieldy polyester and subpar sewing skills.</p>
<p>After consulting with our trusty sewing consultant Sara, we decided on completely avoiding any sewing whatsoever and instead opting for finger condoms, a.k.a. massacred rubber gloves. The flexibility of the rubber proved a perfect tactic for keeping the sensors closely affixed to the fingers and therefore giving us the most accurate readings.</p>
<p>In many respects, the tactile elements of the project are complete as the gloves work largely as advertised. With this part of the project near completion, Ari and I will be focusing on how to refine control over the interface so that the gloves work as expected.</p>
<p>The Processing component has come a long way in the last week. I programmed the integrated samples for the gloves using the¬†<a href="http://code.compartmental.net/tools/minim/">minim</a>¬†sound library, giving us a foundation for eventual behavior of the gloves. However, we still have to calibrate the sensors in order to make sure the samples respond as desired.</p>
<p>Explanations are nice, but ultimately it is a live-working prototype that really speaks for itself. Check out the video below:</p>
<p><a href="http://www.silentlycrashing.net/blog/2008/10/15/tapper-prototype/"><em>Click here to view the embedded video.</em></a></p>
<p><span id="more-215"></span><br />
Our updated Processing code:</p>

<div class="wp_codebox"><table><tr id="p2154"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
</pre></td><td class="code" id="p215code4"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">processing.serial.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ddf.minim.*</span><span style="color: #339933;">;</span>
&nbsp;
AudioPlayer samples<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AudioPlayer<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> val<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> currVal <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> barWidth <span style="color: #339933;">=</span> <span style="color: #cc66cc;">150</span><span style="color: #339933;">;</span>
&nbsp;
Serial port<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  size<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">900</span>, <span style="color: #cc66cc;">256</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  smooth<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  stroke<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  fill<span style="color: #009900;">&#40;</span>#A72F2F<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  port <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>
  port.<span style="color: #006633;">bufferUntil</span><span style="color: #009900;">&#40;</span>‚Äô\n‚Äô<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// start sound engine</span>
  Minim.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// load samples</span>
  <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    samples<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> Minim.<span style="color: #006633;">loadFile</span><span style="color: #009900;">&#40;</span>‚Äùsample‚Äù <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> ‚Äú.<span style="color: #006633;">wav</span>‚Äù<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: #000066; font-weight: bold;">void</span> draw<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  background<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    rect<span style="color: #009900;">&#40;</span>i<span style="color: #339933;">*</span>barWidth, <span style="color: #cc66cc;">0</span>, barWidth, val<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>val<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      samples<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">setVolume</span><span style="color: #009900;">&#40;</span>val<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      samples<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">play</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><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>
&nbsp;
<span style="color: #000066; font-weight: bold;">void</span> serialEvent<span style="color: #009900;">&#40;</span>Serial port<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> inputString <span style="color: #339933;">=</span> port.<span style="color: #006633;">readStringUntil</span><span style="color: #009900;">&#40;</span>‚Äô\n‚Äô<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>inputString <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    inputString <span style="color: #339933;">=</span> trim<span style="color: #009900;">&#40;</span>inputString<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//println(inputString);</span>
    <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> values <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#40;</span>split<span style="color: #009900;">&#40;</span>inputString, ‚Äú,‚Äù<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// make sure we have the right data before assigning values</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>values.<span style="color: #006633;">length</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        val<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> values<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">void</span> stop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    samples<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  Minim.<span style="color: #006633;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.silentlycrashing.net/blog/2008/10/15/tapper-prototype/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Musical tiles at Battery Park</title>
		<link>http://www.silentlycrashing.net/blog/2008/10/14/musical-tiles-at-battery-park/</link>
		<comments>http://www.silentlycrashing.net/blog/2008/10/14/musical-tiles-at-battery-park/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 00:57:59 +0000</pubDate>
		<dc:creator>ez</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[physcomp]]></category>

		<guid isPermaLink="false">http://www.silentlycrashing.net/blog/?p=213</guid>
		<description><![CDATA[I saw a very interesting example of successful interaction design at Battery Park over the weekend. There is a spot on the ground where 9 metal tiles are arranged in a 3&#215;3 pattern. When you step on any of them, they make a sound, and each one has a different tone. For the 30 minutes [...]]]></description>
			<content:encoded><![CDATA[<p>I saw a very interesting example of successful interaction design at Battery Park over the weekend. There is a spot on the ground where 9 metal tiles are arranged in a 3&#215;3 pattern. When you step on any of them, they make a sound, and each one has a different tone.</p>
<p><a href="http://www.silentlycrashing.net/blog/2008/10/14/musical-tiles-at-battery-park/"><em>Click here to view the embedded video.</em></a></p>
<p>For the 30 minutes that I was sitting there, the same scenario kept re-occurring. A couple of people would walk by, someone would try it out, they would stop and play with it, more people would stop and try it, and in a matter of minutes a bunch of strangers would crowd around the piece, jumping around and talking to each other.</p>
<p><a href="http://www.silentlycrashing.net/blog/2008/10/14/musical-tiles-at-battery-park/"><em>Click here to view the embedded video.</em></a></p>
<p>I think this is the best possible interaction scenario that my work could have. It should be instantly recognizable, easy and fun to use, and bring people of all ages together. This is a very difficult thing to achieve, but I think simplicity is a major player and an important factor to remember when designing objects for others to play with.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.silentlycrashing.net/blog/2008/10/14/musical-tiles-at-battery-park/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Etch-A-Sketch 2000</title>
		<link>http://www.silentlycrashing.net/blog/2008/10/14/etch-a-sketch-2000/</link>
		<comments>http://www.silentlycrashing.net/blog/2008/10/14/etch-a-sketch-2000/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 00:14:56 +0000</pubDate>
		<dc:creator>ez</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[physcomp]]></category>

		<guid isPermaLink="false">http://www.silentlycrashing.net/blog/?p=205</guid>
		<description><![CDATA[I did not have an accelerometer for the Multiple Serial Output lab, so I used two potentiometers instead. The result reminded me of an Etch-A-Sketch. I wanted to push this idea further so I built an interface that is exactly the same as an Etch-A-Sketch, but which draws a digital picture on screen. The left [...]]]></description>
			<content:encoded><![CDATA[<p>I did not have an accelerometer for the <a href="http://itp.nyu.edu/physcomp/Labs/SerialDuplex">Multiple Serial Output</a> lab, so I used two potentiometers instead. The result reminded me of an <a href="http://en.wikipedia.org/wiki/Etch_A_Sketch">Etch-A-Sketch</a>. I wanted to push this idea further so I built an interface that is exactly the same as an Etch-A-Sketch, but which draws a digital picture on screen.</p>
<p><a class="tt-flickr tt-flickr-Medium" title="DSC00110" href="http://www.flickr.com/photos/prisonerjohn/2942361677/"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3071/2942361677_545a78bfdb.jpg" alt="DSC00110" width="500" height="375" /></a></p>
<p>The left and right knobs control the horizontal and vertical position of the cursor respectively. If you shake the controller, the image gradually fades away.</p>
<p><a class="tt-flickr tt-flickr-Medium" title="Picture 1" href="http://www.flickr.com/photos/prisonerjohn/2942361959/"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3294/2942361959_8e48c8012d.jpg" alt="Picture 1" width="500" height="375" /></a>¬†<br />
<span id="more-205"></span></p>
<p>I didn&#8217;t want to make the same mistake as with <a href="http://www.silentlycrashing.net/blog/2008/09/16/grade-my-kiss/">Grade My Kiss</a>, which had wires all over the place and didn&#8217;t stand up straight, so I made sure that everything fit nicely in the container and that the wires I used were the right length.</p>
<p><a class="tt-flickr tt-flickr-Medium" title="DSC00113" href="http://www.flickr.com/photos/prisonerjohn/2942361935/"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3217/2942361935_2ac79a4f6a.jpg" alt="DSC00113" width="500" height="375" /></a>¬†</p>
<p>I found a post online about a mock¬†<a href="http://weblogs.asp.net/dwahlin/archive/2007/12/20/great-gift-idea-etch-a-sketch-usb-2-0-adapter.aspx">Etch-A-Sketch USB adapter</a>. I think it&#8217;s a great idea and I would like to extend this project to use a real Etch-A-Sketch as the controller in the near future.</p>
<p>The Arduino code:</p>

<div class="wp_codebox"><table><tr id="p2057"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code" id="p205code7"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//-------------------------------</span>
<span style="color: #666666; font-style: italic;">// Etch-a-sketch 2000</span>
<span style="color: #666666; font-style: italic;">// by Elie Zananiri</span>
<span style="color: #666666; font-style: italic;">// http://www.silentlycrashing.net</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//-------------------------------</span>
<span style="color: #000066; font-weight: bold;">int</span> shakeSwitchPin <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> xPotPin <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> yPotPin <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//-------------------------------</span>
<span style="color: #000066; font-weight: bold;">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: #006633;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//-------------------------------</span>
<span style="color: #000066; font-weight: bold;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">int</span> s <span style="color: #339933;">=</span> digitalRead<span style="color: #009900;">&#40;</span>shakeSwitchPin<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">int</span> x <span style="color: #339933;">=</span> analogRead<span style="color: #009900;">&#40;</span>xPotPin<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">int</span> y <span style="color: #339933;">=</span> analogRead<span style="color: #009900;">&#40;</span>yPotPin<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  Serial.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>x, DEC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Serial.<span style="color: #006633;">print</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>
  Serial.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>y, DEC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Serial.<span style="color: #006633;">print</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>
  Serial.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>s, DEC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  delay<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">25</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The Processing code:</p>

<div class="wp_codebox"><table><tr id="p2058"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
</pre></td><td class="code" id="p205code8"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">processing.serial.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//-------------------------------</span>
<span style="color: #666666; font-style: italic;">// Etch-a-sketch 2000</span>
<span style="color: #666666; font-style: italic;">// by Elie Zananiri</span>
<span style="color: #666666; font-style: italic;">// http://www.silentlycrashing.net</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//----------------------------</span>
Serial port<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">int</span> margin <span style="color: #339933;">=</span> <span style="color: #cc66cc;">70</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> radius <span style="color: #339933;">=</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> threshold <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">boolean</span> firstRun <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">float</span> currX <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">float</span> currY <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">float</span> lastX <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">float</span> lastY <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">float</span> potX <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">float</span> potY <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">boolean</span> drawIt <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">int</span> currShake <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> lastShake <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">boolean</span> shakeIt <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//----------------------------</span>
<span style="color: #000066; font-weight: bold;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  size<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">800</span>, <span style="color: #cc66cc;">600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  smooth<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;">// draw the background</span>
  background<span style="color: #009900;">&#40;</span>#af100c<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  strokeWeight<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  stroke<span style="color: #009900;">&#40;</span>#5A0403<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  fill<span style="color: #009900;">&#40;</span>#d5d5d5<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  erase<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  noStroke<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  strokeWeight<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  erase<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;">// open and set up the serial port</span>
  port <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;">2</span><span style="color: #009900;">&#93;</span>, <span style="color: #cc66cc;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
  port.<span style="color: #006633;">bufferUntil</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//----------------------------</span>
<span style="color: #000066; font-weight: bold;">void</span> draw<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>shakeIt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    noStroke<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    fill<span style="color: #009900;">&#40;</span>#d5d5d5, <span style="color: #cc66cc;">20</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    erase<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    shakeIt <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>drawIt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    stroke<span style="color: #009900;">&#40;</span>#<span style="color: #cc66cc;">141414</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    noFill<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    line<span style="color: #009900;">&#40;</span>lastX, lastY, currX, currY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    drawIt <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</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;">//----------------------------</span>
<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>
  <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> inputString <span style="color: #339933;">=</span> p.<span style="color: #006633;">readStringUntil</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>inputString <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// get the input values</span>
    inputString <span style="color: #339933;">=</span> trim<span style="color: #009900;">&#40;</span>inputString<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> values <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#40;</span>split<span style="color: #009900;">&#40;</span>inputString, <span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// make sure we have the right data before assigning values</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>values.<span style="color: #006633;">length</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;">// get the new coords</span>
      potX <span style="color: #339933;">=</span> map<span style="color: #009900;">&#40;</span>values<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1023</span>, margin, width <span style="color: #339933;">-</span> margin<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      potY <span style="color: #339933;">=</span> map<span style="color: #009900;">&#40;</span>values<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1023</span>, height <span style="color: #339933;">-</span> margin, margin<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// make sure the new values are a big enough change</span>
      <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>abs<span style="color: #009900;">&#40;</span>potX <span style="color: #339933;">-</span> currX<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> threshold <span style="color: #339933;">||</span> abs<span style="color: #009900;">&#40;</span>potY <span style="color: #339933;">-</span> currY<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> threshold<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// store the previous coords</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>firstRun<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          lastX <span style="color: #339933;">=</span> potX<span style="color: #339933;">;</span>
          lastY <span style="color: #339933;">=</span> potY<span style="color: #339933;">;</span>
          firstRun <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
          lastX <span style="color: #339933;">=</span> currX<span style="color: #339933;">;</span>
          lastY <span style="color: #339933;">=</span> currY<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// store the current coords</span>
        currX <span style="color: #339933;">=</span> potX<span style="color: #339933;">;</span>
        currY <span style="color: #339933;">=</span> potY<span style="color: #339933;">;</span> 
&nbsp;
        drawIt <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// get the shake status</span>
      currShake <span style="color: #339933;">=</span> values<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      <span style="color: #666666; font-style: italic;">// if it's different...</span>
      <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>currShake <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">&amp;&amp;</span> currShake <span style="color: #339933;">!=</span> lastShake<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        shakeIt <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #666666; font-style: italic;">// store the previous shake status</span>
      lastShake <span style="color: #339933;">=</span> currShake<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//----------------------------</span>
<span style="color: #000066; font-weight: bold;">void</span> erase<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// draw a rounded rectangle</span>
  rect<span style="color: #009900;">&#40;</span>margin <span style="color: #339933;">+</span> radius, margin, width <span style="color: #339933;">-</span> margin<span style="color: #339933;">*</span><span style="color: #cc66cc;">2</span> <span style="color: #339933;">-</span> radius<span style="color: #339933;">*</span><span style="color: #cc66cc;">2</span>, height <span style="color: #339933;">-</span> margin<span style="color: #339933;">*</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  rect<span style="color: #009900;">&#40;</span>margin, margin <span style="color: #339933;">+</span> radius, width <span style="color: #339933;">-</span> margin<span style="color: #339933;">*</span><span style="color: #cc66cc;">2</span>, height <span style="color: #339933;">-</span> margin<span style="color: #339933;">*</span><span style="color: #cc66cc;">2</span> <span style="color: #339933;">-</span> radius<span style="color: #339933;">*</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  ellipse<span style="color: #009900;">&#40;</span>margin <span style="color: #339933;">+</span> radius, margin <span style="color: #339933;">+</span> radius, radius<span style="color: #339933;">*</span><span style="color: #cc66cc;">2</span>, radius<span style="color: #339933;">*</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  ellipse<span style="color: #009900;">&#40;</span>margin <span style="color: #339933;">+</span> radius, height <span style="color: #339933;">-</span> margin <span style="color: #339933;">-</span> radius, radius<span style="color: #339933;">*</span><span style="color: #cc66cc;">2</span>, radius<span style="color: #339933;">*</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  ellipse<span style="color: #009900;">&#40;</span>width <span style="color: #339933;">-</span> margin <span style="color: #339933;">-</span> radius, height <span style="color: #339933;">-</span> margin <span style="color: #339933;">-</span> radius, radius<span style="color: #339933;">*</span><span style="color: #cc66cc;">2</span>, radius<span style="color: #339933;">*</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  ellipse<span style="color: #009900;">&#40;</span>width <span style="color: #339933;">-</span> margin <span style="color: #339933;">-</span> radius, margin <span style="color: #339933;">+</span> radius, radius<span style="color: #339933;">*</span><span style="color: #cc66cc;">2</span>, radius<span style="color: #339933;">*</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.silentlycrashing.net/blog/2008/10/14/etch-a-sketch-2000/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tapper proposal</title>
		<link>http://www.silentlycrashing.net/blog/2008/10/07/tapper-proposal/</link>
		<comments>http://www.silentlycrashing.net/blog/2008/10/07/tapper-proposal/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 01:57:15 +0000</pubDate>
		<dc:creator>ez</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[physcomp]]></category>

		<guid isPermaLink="false">http://www.silentlycrashing.net/blog/?p=194</guid>
		<description><![CDATA[Ari and I are working together on a project tentatively titled Tapper. The idea came from observing people on the subway who seem very engaged in the music they listen to, by singing, dancing, or tapping their fingers on the walls, poles, seats, their knees, etc. We decided to focus on this last action, and [...]]]></description>
			<content:encoded><![CDATA[<p>Ari and I are working together on a project tentatively titled Tapper. The idea came from observing people on the subway who seem very engaged in the music they listen to, by singing, dancing, or tapping their fingers on the walls, poles, seats, their knees, etc. We decided to focus on this last action, and to create a portable musical instrument played by performing the natural action of tapping your fingers to the beat.¬†</p>
<p>Tapping is a natural response to listening to music and we thought that it could be interesting to actually sequence samples and create music through this action. The action of tapping along with a song seemed like an effective way of turning music appreciators into music producers. We decided to use a glove because we wanted the device to be portable, non-obtrusive, and usable on any surface. Tapper will communicate with a sampler using a common protocol such as MIDI or OSC so that it can interface with any software or platform. Ideally, we would like this to be a portable device like a cellphone or iPod.</p>
<p>The tapping action will be captured using force sensing resistors (FSRs). These seem like the natural choice as we would need to record the different strengths of the taps.</p>
<p><a class="tt-flickr tt-flickr-Medium" href="http://www.flickr.com/photos/prisonerjohn/2923477394/"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3282/2923477394_a818fc894a.jpg" alt="SANY0016" width="375" height="500" /></a></p>
<p>We performed some tests with a rudimentary prototype to get a feel for the action, but also to see the range of values we would get and if that range would change depending on the finger we used.</p>
<p><a href="http://www.silentlycrashing.net/blog/2008/10/07/tapper-proposal/"><em>Click here to view the embedded video.</em></a></p>
<p>According to our graphs:</p>
<ul>
<li>The FSRs capture the strength and range of the taps appropriately when hooking them up with a 22K Œ© resistor.</li>
<li>The range captured seems pretty consistent across all the fingers.</li>
</ul>
<div><a class="tt-flickr tt-flickr-Small" href="http://www.flickr.com/photos/prisonerjohn/2922635283/"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3235/2922635283_e45b9d8a3c_m.jpg" alt="Picture 3" width="240" height="180" /></a>¬†<a class="tt-flickr tt-flickr-Small" href="http://www.flickr.com/photos/prisonerjohn/2923486206/"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3040/2923486206_8eba6451f0_m.jpg" alt="Picture 4" width="240" height="180" /></a>¬†</div>
]]></content:encoded>
			<wfw:commentRss>http://www.silentlycrashing.net/blog/2008/10/07/tapper-proposal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Serial Output Lab</title>
		<link>http://www.silentlycrashing.net/blog/2008/10/05/serial-output-lab/</link>
		<comments>http://www.silentlycrashing.net/blog/2008/10/05/serial-output-lab/#comments</comments>
		<pubDate>Sun, 05 Oct 2008 21:06:43 +0000</pubDate>
		<dc:creator>ez</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[physcomp]]></category>

		<guid isPermaLink="false">http://www.silentlycrashing.net/blog/?p=185</guid>
		<description><![CDATA[I completed the serial output lab and was able to get the Arduino board to communicate with Processing.¬†I used a potentiometer and a pressure sensor as inputs and realised that they had very different readings. ¬† ¬† The potentiometer graph looks fine but the problem is with the pressure sensor. Its range is from -7 [...]]]></description>
			<content:encoded><![CDATA[<p>I completed the serial output lab and was able to get the Arduino board to communicate with Processing.¬†I used a potentiometer and a pressure sensor as inputs and realised that they had very different readings.</p>
<p><a class="tt-flickr tt-flickr-Small" href="http://www.flickr.com/photos/prisonerjohn/2916413120/"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3021/2916413120_8d09f63b39_m.jpg" alt="DSC00075" width="180" height="240" /></a>¬†<a class="tt-flickr tt-flickr-Small" href="http://www.flickr.com/photos/prisonerjohn/2915703137/"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3098/2915703137_9f1d0b314f_m.jpg" alt="graph-0895" width="240" height="180" /></a></p>
<p><a class="tt-flickr tt-flickr-Small" href="http://www.flickr.com/photos/prisonerjohn/2915567255/"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3047/2915567255_03ba509373_m.jpg" alt="DSC00073" width="180" height="240" /></a>¬†<a class="tt-flickr tt-flickr-Small" href="http://www.flickr.com/photos/prisonerjohn/2916548752/"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3082/2916548752_bd0c5cafb1_m.jpg" alt="graph-1217" width="240" height="180" /></a></p>
<p>The potentiometer graph looks fine but the problem is with the pressure sensor. Its range is from -7 to 19. Since a byte is unsigned, -7 gets interpreted as 249 and that&#8217;s where those weird columns come from. Another problem is that since the range is much smaller than 0-255, the graph is not very representative.<br />
<span id="more-185"></span></p>
<p>I wrote my own version of the sensor sketcher which fixes these problems and also adds some new features:</p>
<ul>
<li>The display doesn&#8217;t get reset when it gets full. Instead, the readings move from right to left, like a stock ticker.</li>
<li>You can choose to scale the graph or not, meaning its range will either be 0-1023 or a dynamic min-max range that is calculated at each reading. This is done by pressing &#8216;s&#8217;.</li>
<li>You can read the minimum and maximum values of the displayed graph in the margin on the left.</li>
<li>You can grab a screenshot at any time by pressing the spacebar.</li>
</ul>
<p><a href="http://www.flickr.com/photos/prisonerjohn/2915744411/" class="tt-flickr tt-flickr-Medium"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3251/2915744411_1ccbd1e813.jpg" alt="graph-0459" width="500" height="160" /></a></p>

<div class="wp_codebox"><table><tr id="p18510"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
</pre></td><td class="code" id="p185code10"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">processing.serial.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Sensor sketcher
 * by Elie Zananiri
 * ITP Physical Computing, 04/10/2008
 *
 * SPACE captures an image
 * 's' toggles scaling
 */</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//-------------------------------</span>
<span style="color: #666666; font-style: italic;">// variables</span>
Serial port<span style="color: #339933;">;</span>
PFont monaco<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">int</span> arraySize <span style="color: #339933;">=</span> <span style="color: #cc66cc;">200</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> data<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span>arraySize<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> margin <span style="color: #339933;">=</span> <span style="color: #cc66cc;">30</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">float</span> barWidth<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">int</span> minVal <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1024</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> maxVal <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">boolean</span> scaled <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//-------------------------------</span>
<span style="color: #000066; font-weight: bold;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  size<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">800</span>, <span style="color: #cc66cc;">256</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  smooth<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  frameRate<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  monaco <span style="color: #339933;">=</span> loadFont<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Monaco-12.vlw&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  textFont<span style="color: #009900;">&#40;</span>monaco, <span style="color: #cc66cc;">12</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  stroke<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  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>
&nbsp;
  barWidth <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>width <span style="color: #339933;">-</span> margin<span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#40;</span>arraySize<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// reset the data</span>
  <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> arraySize<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    data<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  port <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;">2</span><span style="color: #009900;">&#93;</span>, <span style="color: #cc66cc;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//-------------------------------</span>
<span style="color: #000066; font-weight: bold;">void</span> draw<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  background<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// draw the bounds</span>
  textAlign<span style="color: #009900;">&#40;</span>LEFT, TOP<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>scaled<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    text<span style="color: #009900;">&#40;</span>maxVal, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
    text<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;1024&quot;</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  textAlign<span style="color: #009900;">&#40;</span>LEFT, BOTTOM<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>scaled<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    text<span style="color: #009900;">&#40;</span>minVal, <span style="color: #cc66cc;">0</span>, height<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
    text<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;0&quot;</span>, <span style="color: #cc66cc;">0</span>, height<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// draw all the data</span>
  <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> arraySize<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">float</span> barHeight<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>scaled<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      barHeight <span style="color: #339933;">=</span> height <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> minVal<span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#40;</span>maxVal <span style="color: #339933;">-</span> minVal<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
      barHeight <span style="color: #339933;">=</span> data<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>height<span style="color: #339933;">/</span>1024.0f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    rect<span style="color: #009900;">&#40;</span>i<span style="color: #339933;">*</span>barWidth <span style="color: #339933;">+</span> margin, height <span style="color: #339933;">-</span> barHeight, barWidth, barHeight<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;">//-------------------------------</span>
<span style="color: #000066; font-weight: bold;">void</span> serialEvent <span style="color: #009900;">&#40;</span>Serial port<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// move all the data back to make space for the new one</span>
  <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> arraySize<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    data<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> data<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// get the byte</span>
  <span style="color: #000066; font-weight: bold;">int</span> in <span style="color: #339933;">=</span> port.<span style="color: #006633;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  data<span style="color: #009900;">&#91;</span>arraySize<span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> in<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// adjust the bounds</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>in <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> minVal<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    minVal <span style="color: #339933;">=</span> in<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>in <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> maxVal<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    maxVal <span style="color: #339933;">=</span> in<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;">//-------------------------------</span>
<span style="color: #000066; font-weight: bold;">void</span> keyPressed<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>key <span style="color: #339933;">==</span> <span style="color: #0000ff;">' '</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    saveFrame<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;graph-&quot;</span> <span style="color: #339933;">+</span> nf<span style="color: #009900;">&#40;</span>frameCount, <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>key <span style="color: #339933;">==</span> <span style="color: #0000ff;">'s'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    scaled <span style="color: #339933;">=</span> <span style="color: #339933;">!</span>scaled<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.silentlycrashing.net/blog/2008/10/05/serial-output-lab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Servo Lab</title>
		<link>http://www.silentlycrashing.net/blog/2008/09/25/servo-lab/</link>
		<comments>http://www.silentlycrashing.net/blog/2008/09/25/servo-lab/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 19:20:52 +0000</pubDate>
		<dc:creator>ez</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[physcomp]]></category>

		<guid isPermaLink="false">http://www.silentlycrashing.net/blog/?p=141</guid>
		<description><![CDATA[I just did the servo lab. It was pretty straightforward; I got it to work with both the original version and the new Servo library in Arduino 0012.]]></description>
			<content:encoded><![CDATA[<p>I just did the servo lab. It was pretty straightforward; I got it to work with both the original version and the new Servo library in Arduino 0012.<br />
<a href="http://www.flickr.com/photos/prisonerjohn/2888374144/" class="tt-flickr tt-flickr-Medium"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3069/2888374144_d25d277527.jpg" alt="DSC00059" width="500" height="375" /></a> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.silentlycrashing.net/blog/2008/09/25/servo-lab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>24 Switches</title>
		<link>http://www.silentlycrashing.net/blog/2008/09/22/24-switches/</link>
		<comments>http://www.silentlycrashing.net/blog/2008/09/22/24-switches/#comments</comments>
		<pubDate>Mon, 22 Sep 2008 16:16:44 +0000</pubDate>
		<dc:creator>ez</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[physcomp]]></category>

		<guid isPermaLink="false">http://www.silentlycrashing.net/blog/?p=133</guid>
		<description><![CDATA[This is how I think that installation with the 24 switches works:]]></description>
			<content:encoded><![CDATA[<p>This is how I think that installation with the 24 switches works:<br />
<a class="tt-flickr tt-flickr-Medium" href="http://www.flickr.com/photos/prisonerjohn/2879601726/"><img class="aligncenter thumb" src="http://farm4.static.flickr.com/3230/2879601726_a6c5b9abbe.jpg" alt="24 switches" width="325" height="500" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.silentlycrashing.net/blog/2008/09/22/24-switches/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>&#8220;Understanding Electricity&#8221; Lab</title>
		<link>http://www.silentlycrashing.net/blog/2008/09/20/understanding-electricity-lab/</link>
		<comments>http://www.silentlycrashing.net/blog/2008/09/20/understanding-electricity-lab/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 20:04:44 +0000</pubDate>
		<dc:creator>ez</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[physcomp]]></category>

		<guid isPermaLink="false">http://www.silentlycrashing.net/blog/?p=108</guid>
		<description><![CDATA[Here are some stills from the &#8220;Understanding Electricity&#8221; lab for Physical Computing. ¬†]]></description>
			<content:encoded><![CDATA[<p>Here are some stills from the &#8220;Understanding Electricity&#8221; lab for Physical Computing.</p>
<p><a class="tt-flickr tt-flickr-Small" href="http://www.flickr.com/photos/prisonerjohn/2872731769/"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3186/2872731769_bb55843fa7_m.jpg" alt="DSC00028" width="240" height="180" /></a> <a class="tt-flickr tt-flickr-Small" href="http://www.flickr.com/photos/prisonerjohn/2872731867/"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3135/2872731867_3ec817af42_m.jpg" alt="DSC00032" width="240" height="180" /></a></p>
<p><a class="tt-flickr tt-flickr-Small" href="http://www.flickr.com/photos/prisonerjohn/2873561884/"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3263/2873561884_1e561c3c2a_m.jpg" alt="DSC00035" width="240" height="180" /></a>¬†<a class="tt-flickr tt-flickr-Small" href="http://www.flickr.com/photos/prisonerjohn/2872732621/"><img class="alignnone thumb" src="http://farm4.static.flickr.com/3095/2872732621_64d2803bc6_m.jpg" alt="DSC00037" width="240" height="180" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.silentlycrashing.net/blog/2008/09/20/understanding-electricity-lab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

