<?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>Jeff Kirsch</title>
	<atom:link href="http://jeffkirsch.com/thoughtsandthings/feed/" rel="self" type="application/rss+xml" />
	<link>http://jeffkirsch.com/thoughtsandthings</link>
	<description>Thoughts, projects and other random things</description>
	<lastBuildDate>Thu, 31 Dec 2009 02:41:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Touchstone Final Wrap-Up</title>
		<link>http://jeffkirsch.com/thoughtsandthings/2009/12/26/touchstone-final-wrap-up/</link>
		<comments>http://jeffkirsch.com/thoughtsandthings/2009/12/26/touchstone-final-wrap-up/#comments</comments>
		<pubDate>Sat, 26 Dec 2009 17:19:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coursework]]></category>
		<category><![CDATA[Fundamentals of Physical Computing]]></category>

		<guid isPermaLink="false">http://jeffkirsch.com/thoughtsandthings/2009/12/26/touchstone-final-wrap-up/</guid>
		<description><![CDATA[Touchstone

The Touchstone is a device by John Finley, Angela Huang and Jeff Kirsch that allows users to exchange a touch at a distance. In its current iteration, it uses light to communicate touch across a room. In further iterations, the Touchstone will use an internet relay to allow a pair of devices to communicate from [...]]]></description>
			<content:encoded><![CDATA[<h3>Touchstone</h3>
<p><a href="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/12/me_you.jpg"><img src="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/12/me_you-1024x768.jpg" alt="" title="Touchstone" width="600" height="450" class="aligncenter size-large wp-image-178" /></a></p>
<p>The Touchstone is a device by John Finley, Angela Huang and Jeff Kirsch that allows users to exchange a touch at a distance. In its current iteration, it uses light to communicate touch across a room. In further iterations, the Touchstone will use an internet relay to allow a pair of devices to communicate from anywhere in the world. The story of its development to date follows.</p>
<h2>Origins and Ideation</h2>
<p>In brainstorming projects for the final, we began by identifying a number of broad themes of interest, including:</p>
<ul>
<li>Action at a distance</li>
<li>Visualizing the invisible</li>
<li>Multiple small parts acting as one</li>
<li>Bringing the distant closer</li>
<li>Ambient communication</li>
</ul>
<p>From there, we brainstormed a variety of projects that touched on one or more of these points. One in particular emerged as interesting to the entire group, and seemingly plausible within the timeframe of the project.</p>
<p>Whether just across town, or somewhere on the other side of the world, everyone in the studio has someone they care about deeply but see considerably less than they&#8217;d like. A number of mechanisms exist for sending composed messages to these people, in phone calls, emails, IMs, text messages, etc. But what about simply communicating a &#8220;Thinking about you,&#8221; without the added overhead of words? The deceptively simple way a touch communicates that sentiment was the genesis of our Distant Touch concept, which evolved into the Touchstone.</p>
<h2>Original Concept</h2>
<p>As originally conceived, the Touchstone system would consist of a pair of desktop devices. When touched, the local device would sense the heat from the user&#8217;s hand and send a signal to its distant partner, causing the remote device to heat up. The more a Touchstone was touched, the hotter the remote device would become, to a maximum heat. Touchstones would &#8220;cool&#8221; much faster than they&#8217;d heat, which meant that communication of a touch was asynchronous; a remote stone would be hot to the touch if its partner was touched recently, or frequently. On Rob&#8217;s advice, we attempted to consider a bit more of the complexity of relationships, allowing the Touchstone to become actively cold if neglected.</p>
<p>There were a number of points we found compelling in this original conception. The idea of translating the heat of a touch into an electronic signal, and then back to heat on the other side seemed a novel analog to the translation of voice, images and text that we&#8217;re already quite familiar with. Additionally, the fact that the device responds to touch, and its output (heat) can only be sensed through touching meant there&#8217;d be no way to determine the state of the &#8220;conversation&#8221; without effecting it.</p>
<p>From a technical perspective, we quickly realized that attempting to sense the heat of a touch in a device that heats up would likely lead to a variety of headaches in the form of feedback loops, we decided to instead use a capacitive sensor as a digital touch trigger, simply counting the length of a touch, and incrementing the programatic &#8220;heat&#8221; accordingly.</p>
<p>We also realized that getting a Peltier Junction in our hands and working would be difficult for the first iteration, and instead simulated heat through an LED that went from blue (cold) to red (hot.)</p>
<h2>Differentiation of Labor</h2>
<p>In order to best use each person&#8217;s skills, we decided to split out the various tasks involved in developing the prototype. Angela, with her background in Industrial Design, dove into formal studies for the shape of the device, and essential element in building something that afforded touching and could present a &#8220;neutral&#8221; posture from which to express presence or absence. Finley, one of two people in our class who could properly be called programmers, concentrated on the software while I worked in tandem building out the hardware. In reality, we both moved between both of these roles, troubleshooting each other&#8217;s code and wiring at three in the morning. As much as possible, we were all involved in the bigger picture interaction questions, and I took something of a role of keeping an eye on where the various pieces of the project were and creating informal landmarks for development.</p>
<h2>First Iteration and Feedback</h2>
<p>The first iteration of the Touchstone brought together a number of in-progress bits to give the class a general idea of where the project was going. It incorporated a blue to red heat-simulating LED, in addition to capacitive proximity sensor, all hidden under a hollow styrofoam orb. As there was only one device, we rigged the prototype to &#8220;heat&#8221; itself up, so that when touched, it actually displayed the state of the imaginary remote stone. The untouched device sat on the table glowing blue; when touched the color would become increasingly red, until a point where the orb glowed purely red. When the touching hand was removed, the device would slowly &#8220;cool&#8221; back to blue.</p>
<p>We gained some useful insight from this simple demonstration. First, we learned that although we intended the LEDs to serve only as a stand-in for heat, the class found the lights to be very compelling. Second, when we explained that the response they saw was in fact that of the remote device, our classmates raised their concern about the lack of a local verification of interaction, and indication of the state of the remote device. We took both of these into consideration as we moved forward with prototype.</p>
<h2>Faking It (Second Iteration)</h2>
<p>From the beginning, we realized that we wouldn&#8217;t really know much about how the interaction worked until people tried it, so we set about trying to make as &#8220;real&#8221; of a prototype as we could as quickly as possible. Unfortunately, technical progress came slower than we&#8217;d hoped, and by the second demonstration, we&#8217;d just barely gotten two Touchstone mockups to communicate over a wired serial connection. Rob encouraged us to consider building a simple man-behind-the-curtain prototype to allow people to better experience and respond to a demonstrated interaction. We quickly decided to fork the development once again, with Angela continuing work on the form of the device and Finley taking on primary responsibility for the software and hardware of what would become the eventual for-presentation prototype, while I quickly built and coded a potentiometer-controlled, two-LED interaction model.</p>
<div id="attachment_177" class="wp-caption aligncenter" style="width: 610px"><a href="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/12/interaction_model.jpg"><img src="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/12/interaction_model-1024x768.jpg" alt="" title="Interaction Model" width="600" height="450" class="size-large wp-image-177" /></a><p class="wp-caption-text">The man-behind-the-curtain Touchstone</p></div>
<p>The benefits were immediate and obvious. Before even getting the device into classmate&#8217;s hands, seeing the &#8220;remote&#8221; and &#8220;local&#8221; heat indicator lights both fully &#8220;hot&#8221; suggested the need for a special state when both devices were touched simultaneously; I quickly added a &#8220;heartbeat&#8221; pulse on both devices to indicate as much. This, in turn, helped us realize that the interaction was not so much about heating or cooling the Touchstone over the longterm, but instead about a synchronous communication of presence. Heartbeat state enabled, we let people play with it.</p>
<p><object width="600" height="450"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=8459999&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=8459999&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="450"></embed></object>
<p><a href="http://vimeo.com/8459999">Two-color Touchstone interaction test</a> from <a href="http://vimeo.com/user1269179">Jeff Kirsch</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Again, a number of insights immediately came of the first hands-on tests. Parts of the interaction seemed natural enough, but it was unclear what each light indicated without being able to see what was (or wasn&#8217;t) happening with the other device. Additionally, having multiple colors plus a &#8220;pulse&#8221; seemed too much for a device as simple as this. Blue didn&#8217;t map to &#8220;cold&#8221; or &#8220;neglected&#8221; as well as red mapped to &#8220;hot&#8221; or &#8220;maintained,&#8221; and the range of purples in between didn&#8217;t seem to map to anything at all. We&#8217;d been sticking too closely to our simulation of hot and cold, and realized that &#8220;off&#8221; served better than blue to indicate that the devices weren&#8217;t touched, allowing the increasingly bright red light paired with the heartbeat pulse to communicate more clearly. We also played with some labeling for the local and remote indicators on the stone. </p>
<p>Our success in this was confirmed when testers started to respond, unprompted, with realization and delight at the appearance of the heartbeat pulse, even in our obvious curtain-less test.</p>
<p><object width="600" height="450"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=8460740&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=8460740&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="450"></embed></object>
<p><a href="http://vimeo.com/8460740">One-color Touchstone interaction test</a> from <a href="http://vimeo.com/user1269179">Jeff Kirsch</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Somewhere in the midst of these various discoveries, we were able to get wireless communication working, and to pull elements of code from the interaction prototype into the actual device prototype. A video of the first successful test (where we somewhat confusingly use a blue LED to indicate the remote side) follows:</p>
<p><object width="600" height="450"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=8353097&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=8353097&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="450"></embed></object>
<p><a href="http://vimeo.com/8353097">Two color touchstone communication test</a> from <a href="http://vimeo.com/user1269179">Jeff Kirsch</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<h2>Technical Decisions</h2>
<p>With our final presentation quickly approaching, we realized some decisions had to made as to which features and functionality would make it into the final prototype. We&#8217;d done some testing with a Peltier Junction, but the difficulties of thermodynamics, paired with the success of our LED-based mock-ups led us to drop the heat angle without much remorse. We&#8217;d also been hoping to make all the electronics for the final product fit within the shell of the Touchstone itself (by this time, beautifully rendered in acrylic by Angela) but realized after a short feasibility meeting that the benefits of spending the required time and energy to attempt that goal would be much less than spending that time ensuring that we had two identical, reliably communicating Touchstones exhibiting the desired interaction model. A similar calculation caused us to, with somewhat more remorse, abandon our attempts as making the capacitive sensing work (replacing it instead with a force sensor, which left the interaction identical from the user&#8217;s perspective) and of making it possible for the devices to communicate at a range beyond what could be achieved with the xBee radios (a more problematic concession, and one we plan to address in future iterations.)</p>
<h2>Final Prototype</h2>
<p>For our final presentation, we built two electronically and programmatically identical devices, each with a pair of red LEDs, a force sensor and an xBee radio to communicate with their partner device.</p>
<p>Programmatically, the stones still use a &#8220;heating&#8221; metaphor. Each time through the code, we check for any pressure on the device. If pressure is sensed, we increment a counter by one (to a maximum of 255), and transmit the value of that counter over the radio, while simultaneously lighting the local LED with a corresponding value. If no pressure is sensed, we decrement the counter and do the same, down to a level of zero.</p>
<p>On the receiving end, each stone simply reads its serial port, and sets a &#8220;remote heat&#8221; variable to the received value. The remote LED lights accordingly. If no good value is received, the variable remains at the last good value. This bare-bones approach (we&#8217;d initially attempted to transmit a single character to indicate touch, and to have each stone increment or decrement the remote value internally) not only greatly simplified our code, but made the system appear much smoother and more reliable to the user.</p>
<p>Physically, we used Angela&#8217;s finished acrylic model, as well as a foam form model. We put LEDs in each and force sensors on the bottoms, and set them up on a piece of cloth, running the umbilical cable hidden underneath to and under-table box with the rest of the hardware. The two Touchstones were set up on opposite sides of the room.</p>
<p>The setup worked convincingly enough to spark a critique about the nature of the interaction, rather than the fidelity of the prototype, and by that measure it was certainly a success.</p>
<p>A video of the final prototype, showing one side of the interaction:</p>
<p><object width="600" height="450"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=8071438&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=8071438&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="450"></embed></object>
<p><a href="http://vimeo.com/8071438">Touchstone Demonstration</a> from <a href="http://vimeo.com/user1269179">Jeff Kirsch</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<h2>Attempted Revisions</h2>
<p>Prior to the final class meeting, we attempted three different additions to the prototype. At the suggestion of one of our guest reviewers to make the Touchstones more responsive physically, Angela incorporated memory foam into a second acrylic model. Finley and I worked to get an ideally more reliable capacitive sensor back into the equation, but quickly realized that we were once again going down the wrong path by trying to develop a makeshift solution for something that could be easily achieved with the right components, and that made little obvious difference to the user in the long run.</p>
<p>We did, however, make a serious attempt at adding a second level of interaction, namely, the ability to squeeze the Touchstone and have that physically manifest itself (through a concentrated vibration) on the remote device. While ultimately unsuccessful, we got far enough to know what needed to be accomplished to implement that new functionality, changing the &#8220;heat&#8221; values imperceptibly from 0-255 to 0-254, and using a value of 255 to indicate that the remote device was being squeezed. This would then cause a small vibrator motor (embedded in the memory foam) to vibrate.</p>
<h2>Next Steps</h2>
<p>We all learned a lot from working on the Touchstone, and by the end of class found ourselves every bit (if not more) interested in the project as we were at the beginning. We&#8217;re planning to continue development as time allows, concentrating on a few important areas.</p>
<p>First, we plan to find a way to make the device work from different locations. This is an essential part of the interaction that fundamentally changes the way the Touchstone is perceived, and potentially, the viability of the solutions we&#8217;ve out in place thus far. Part of this is making it capable of connecting to the internet, and another (I&#8217;m convinced) is getting it into a condensed, stable package. Neither is trivial, but they both should be well within our abilities.</p>
<p>Second, we&#8217;d like to continue refining the form. At present, there&#8217;s something unresolved about the texture of the device, and we need to determine if the addition of memory foam hurts that or helps. There&#8217;s also a difference of opinions about the organic shape of the device, whether it&#8217;s too much or not enough.</p>
<p>Both these things will help us in the key determinations we need to make about the fundamental interaction. Ultimately, is it successful? Does it compellingly provide a new means of communicating presence and care at a distance? Does it appropriately allow for the opposite to be communicated? Must it? In the end, the only way to tell is to get the devices out in the world, in the hands of users, and observe the results.</p>
<p>Code, as used in the final demo is below:<br />
<code><br />
/*<br />
 _____                _         _<br />
|_   _|__  _   _  ___| |__  ___| |_ ___  _ __   ___<br />
  | |/ _ \| | | |/ __| '_ \/ __| __/ _ \| '_ \ / _ \<br />
  | | (_) | |_| | (__| | | \__ \ || (_) | | | |  __/<br />
  |_|\___/ \__,_|\___|_| |_|___/\__\___/|_| |_|\___|</p>
<p>by John P. Finley, Angela Huang, and Jeff Kirsch</p>
<p>December 9th, 2009 for Presentation to Rob Faludi's<br />
Fundamentals of Physical Computing class at the<br />
School of Visual Arts MFA Interaction Design program,<br />
December 2009.</p>
<p>http://interactiondesign.sva.edu/classes/physicalcomputing/</p>
<p>Portions based on Heartbeat LED by elCalvoMike 12-6-2008<br />
*/</p>
<p>// Variable Setup<br />
#define localLED 9                // Local LED attached to PWM 9<br />
#define remoteLED 10              // Remote LED attached to PWM 9</p>
<p>int incomingByte = 0;             // variable to store the read value<br />
int localHeat = 0;                // variable to store the read value<br />
int remoteHeat = 0;               // variable to store the read value</p>
<p>int i = 0;                        // variable to store the read value<br />
int rate = 20;                    // variable to store the read value</p>
<p>int analogPin = 0;                // variable to store the read value<br />
int val = 0;                      // variable to store the read value</p>
<p>// The setup opens serial comm and initializes our LED pins.<br />
void setup(){<br />
  Serial.begin(9600);             // open serial communication<br />
  pinMode(localLED, OUTPUT);      // sets the digital pin as output<br />
  pinMode(remoteLED, OUTPUT);     // sets the digital pin as output<br />
}</p>
<p>// The rundown:<br />
// First, see if the device is being touched. Modify<br />
// the heat counters appropriately. Then write that<br />
// value to the serial for the other device to read.<br />
// Read the other device's heat vlaue over serial.<br />
// Light up the two LEDs based on those values.<br />
void loop(){<br />
  checkIfIAmTouched();<br />
  talkToOtherDevice();<br />
  listenForOtherDevice();<br />
  lightLEDs();<br />
}</p>
<p>//**************************************************//<br />
//**************************************************//</p>
<p>// Ask the FSR if there is anything happening.<br />
// If we are getting a value, we are being touched,<br />
// so increment the heat counter. If we have no<br />
// value, we are being left alone so decrement.<br />
// Delay to prevent doom.<br />
void checkIfIAmTouched(){<br />
  if (analogRead(analogPin) > 0 ){<br />
    makeThingsHotter();<br />
  }<br />
  else{<br />
    makeThingsColder();<br />
  }<br />
  delay(10);<br />
}</p>
<p>// Print out this devices' heat value to the other device.<br />
void talkToOtherDevice(){<br />
  Serial.write(localHeat);<br />
}</p>
<p>// Read the serial buffer. If there is something there,<br />
// assign that value as the heat of the remote device.<br />
// Flush the serial port to prevent doom.<br />
void listenForOtherDevice(){<br />
  if (Serial.available() > 0){<br />
    remoteHeat = Serial.read();<br />
    Serial.flush();<br />
  }<br />
}</p>
<p>// Increment this device's heat value unless it<br />
// hits a ceiling of 255.<br />
void makeThingsHotter(){<br />
  if (localHeat < 255){<br />
    localHeat++;<br />
  }<br />
}</p>
<p>// Decrement this device's heat value unless it<br />
// hits zero.<br />
void makeThingsColder(){<br />
  if (localHeat > 0){<br />
    localHeat--;<br />
  }<br />
}</p>
<p>// Light both the LEDs with their proper values.<br />
// If both heat values are at maximum, we are holding<br />
// hands; time to start the heartbeat animation.<br />
// If no, just give the value that has been determined<br />
// by makeThingsHotter() or Colder().<br />
void lightLEDs(){<br />
  if(localHeat == 255 &#038;&#038; remoteHeat == 255){<br />
    heartPulse();<br />
  }<br />
  else{<br />
    analogWrite(localLED, localHeat);<br />
    analogWrite(remoteLED, remoteHeat);<br />
  }<br />
}</p>
<p>// Hearbeat simulation animiation.<br />
// From full brightness go down slightly,<br />
// then up and then down for a while.<br />
// Inspired by elCalvoMike.<br />
void heartPulse(){<br />
 for (i = 255; i > 100; i--){<br />
   analogWrite(remoteLED,i);<br />
   analogWrite(localLED,i);<br />
   delay(((60000/rate)*.1)/255);<br />
 }<br />
 for(i = 100; i < 255; i++) {<br />
   analogWrite(remoteLED,i);<br />
   analogWrite(localLED,i);<br />
   delay(((60000/rate)*.2)/255);<br />
 }<br />
 for (i = 255; i > 100; i--){<br />
   analogWrite(remoteLED,i);<br />
   analogWrite(localLED,i);<br />
   delay(((60000/rate)*.1)/255);<br />
 }<br />
 for(i = 100; i < 255; i++) {<br />
   analogWrite(remoteLED,i);<br />
   analogWrite(localLED,i);<br />
   delay(((60000/rate)*.6)/255);<br />
 }<br />
}<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://jeffkirsch.com/thoughtsandthings/2009/12/26/touchstone-final-wrap-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wireless Lab</title>
		<link>http://jeffkirsch.com/thoughtsandthings/2009/12/16/wireless-lab/</link>
		<comments>http://jeffkirsch.com/thoughtsandthings/2009/12/16/wireless-lab/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 17:13:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coursework]]></category>
		<category><![CDATA[Fundamentals of Physical Computing]]></category>

		<guid isPermaLink="false">http://jeffkirsch.com/thoughtsandthings/?p=163</guid>
		<description><![CDATA[In the final lab for Fundamentals of Physical Computing, we make a wireless doorbell using a bunch of familiar parts, with the addition of an XBee radio. After a little bit of configuration and some careful wiring, there&#8217;s really nothing new to be found here. The XBee simply acts like a &#8220;wire-free&#8221; serial connection, passing [...]]]></description>
			<content:encoded><![CDATA[<p>In the final lab for Fundamentals of Physical Computing, we make a wireless doorbell using a bunch of familiar parts, with the addition of an <a href="http://www.digi.com/products/wireless/point-multipoint/xbee-series1-module.jsp#overview">XBee</a> radio. After a little bit of configuration and some careful wiring, there&#8217;s really nothing new to be found here. The XBee simply acts like a &#8220;wire-free&#8221; serial connection, passing anything written to serial, verbatim, to the paired radio. Many thanks to <a href="http://www.heyfinley.com/">Finley</a> for being my project partner on this, as well as the Touchstone, where we made significant use of wireless comm.</p>
<h2>Prep work</h2>
<p>All told, the most challenging part of the lab may have been simply getting the radio into the circuit.</p>
<div id="attachment_165" class="wp-caption aligncenter" style="width: 310px"><a href="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/12/XBEE_Breakout.JPG"><img src="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/12/XBEE_Breakout-300x225.jpg" alt="Fully soldered XBee breakout board." title="XBee Breakout Board" width="300" height="225" class="size-medium wp-image-165" /></a><p class="wp-caption-text">Fully soldered XBee breakout board.</p></div>
<p>Because the XBee uses closely-spaced pins, it can&#8217;t fit directly into the breadboard. Sparkfun sells a great <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=8276">breakout board</a> to deal with just this issue, but it comes without headers and requires a lot of tiny joins. 40 in all. It&#8217;s actually not a bad way to hone those soldering skills.</p>
<h2>Wiring</h2>
<p>From there, hooking up the breakout boards is simply a matter of connecting VCC to 3.3v power (the XBees can&#8217;t work at 5v, and will fry at 7,) and ground, as well as DOUT to the Arduino Rx pin, and DIN to the Arduino Tx pin. This actually caused a bit of confusion in the studio, as In and Out are obviously device-relative and labeling isn&#8217;t standard.</p>
<p>Beyond that, hooking up the button and buzzer, or in our case, an LED, was a straightforward operation.</p>
<h2>Programming the radios, and a cautionary tale of XBee + Arduino</h2>
<p>The XBee radios are programable through standard AT commands. While experimenting with the radios prior to the lab, we&#8217;d attempted to use &#8220;screen&#8221; on the command line, which is something less than a pleasure. Funnel.cc&#8217;s <a href="http://code.google.com/p/funnel/downloads/list">XBeeConfigTerminal</a> makes everything much, much easier, and we were rapidly able to pair the radios that way.</p>
<p>At this point, you&#8217;d think we&#8217;d be ready to drop the example code into Arduino and upload it to the board, but there&#8217;s a slight and important caveat. Because there is only one channel of serial communication on the Arduino, it&#8217;s essential that the Rx pin be unplugged from the radio, or any other potential input, prior to attempting to upload code. Otherwise, the board will enter a mode where it&#8217;s ready to be programmed, but be confused as to the source of that information. This causes the board to become out of sync with the IDE, and requires a bit of unplugging and re-plugging to get things sorted out. If you&#8217;re able to remember this, however, the whole operation goes fairly smoothly.</p>
<h2>Simple and feedback doorbells</h2>
<p>While the simple doorbell just triggers an alert on the board, the second bit of code sends a confirmation back, and lights an LED on the sending board. By unplugging the Rx and Tx pins, we&#8217;re able to show that the feedback really does come from the remote unit.</p>
<p>A demo of the operating (silent) feedback doorbell is below.</p>
<p><object width="500" height="375"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=8218821&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=8218821&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="500" height="375"></embed></object>
<p><a href="http://vimeo.com/8218821">Wireless Lab Video</a> from <a href="http://vimeo.com/user1269179">Jeff Kirsch</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<h2>Final thoughts</h2>
<p>This simple exercise gave us most of the tools we needed to move forward with wireless communication on the Touchstone. While two boards communicating back and forth while running identical code is more difficult to achieve than a pair of boards with different code, the same fundamental lessons (especially unplugging the radios before upload) apply.</p>
<p>Full lab info available <a href="http://interactiondesign.sva.edu/classes/physicalcomputing/labs/lab-wireless/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffkirsch.com/thoughtsandthings/2009/12/16/wireless-lab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Midterm Project</title>
		<link>http://jeffkirsch.com/thoughtsandthings/2009/11/18/midterm-project/</link>
		<comments>http://jeffkirsch.com/thoughtsandthings/2009/11/18/midterm-project/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 05:16:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coursework]]></category>
		<category><![CDATA[Fundamentals of Physical Computing]]></category>

		<guid isPermaLink="false">http://jeffkirsch.com/thoughtsandthings/?p=147</guid>
		<description><![CDATA[SAVI &#8211; The Smart Audio Volume Indicator
The project Evinn Quinn, Stephanie Aaron and I decided to take on for our midterm was a system for indicating to cell-phone talkers when they&#8217;re speaking too loudly for the context they&#8217;re in, a product we call SAVI, or Smart Audio Volume Indicator
Problem Realization
In our project development conversations, we [...]]]></description>
			<content:encoded><![CDATA[<h3>SAVI &#8211; The Smart Audio Volume Indicator</h3>
<p>The project Evinn Quinn, Stephanie Aaron and I decided to take on for our midterm was a system for indicating to cell-phone talkers when they&#8217;re speaking too loudly for the context they&#8217;re in, a product we call SAVI, or Smart Audio Volume Indicator</p>
<h2>Problem Realization</h2>
<p>In our project development conversations, we came upon the problem of people speaking at contextually inappropriate volume levels in public spaces. Be it the bus, the elevator or the bank line, we could all recall instances of this happening.</p>
<p>In most cases, these people were on cell phones, and while some may simply not have cared who else they might be bothering, we came to believe most were simply unaware of the volume at which they were speaking.</p>
<p>In our anecdotal observations, we&#8217;ve seen that this can lead to embarrassing leaks of private information, and uncomfortable social situations for all involved. Potentially, these situations can escalate to confrontation or violence. In short, it seemed an issue worthy of addressing.</p>
<h2>Solution Formulation</h2>
<p>Honing in on the frequency with which manifestations of the problem involved cell phones, we decided to pursue a cell phone-specific solution. Equipped with a microphone and a variety of potential outputs, it seemed the perfect platform. As we&#8217;re not cell-phone developers, however, we decided to prototype the behavior by building our own device.</p>
<p>We recognized the basic components of a solution were these: We&#8217;d need to measure the volume of the ambient noise in a space, measure the volume of the phone user&#8217;s speech, compare these values (with some sort of allowance for speaking over background noise,) and provide feedback to the speaker if a certain difference was exceeded.</p>
<p>We considered a variety of possible outputs, from a tapping on the shoulder to a whisper in the ear which got progressively louder as the transgression persisted to some form of vibration. To begin, however, we decided to tackle the input and signal comparison problems.</p>
<h2>First Iteration</h2>
<p>For the first iteration, we decided to table to output discussion, and concentrate on dealing with inputs and programatic comparison of levels. While we were able to find schematics for a microphone and amplifier circuit, and get ahold of the various parts needed to assemble it, we found the range of values we were able to pick up was too small to even be sure the input was working correctly. Not wanting to waste time, we decided to fake the inputs as well, and deal primarily with the programming and behavioral logic of detection and alerts.<br />
<div id="attachment_152" class="wp-caption aligncenter" style="width: 610px"><a href="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/11/IMG_0919.JPG"><img src="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/11/IMG_0919-1024x768.jpg" alt="First Iteration" title="First Iteration" width="600" height="450" class="size-large wp-image-152" /></a><p class="wp-caption-text">First Iteration</p></div></p>
<p>Along those lines, we built a prototype consisting of two potentiometers (one to set the &#8220;background&#8221; volume, and another the volume of the phone user&#8217;s voice) and an LED hooked up to an analog pin as our output (we knew from the beginning that we&#8217;d want the output, whatever it would be, to scale with the intensity or persistence of the loud talking.</p>
<p>We fairly quickly arrived at a simple bit of code to compare the two inputs, with a defined &#8220;alert delta&#8221; required to trigger an alert. Over this threshold, the LED lit in realtime to a brightness determined by the difference between the speech volume and the background volume. Code follows:</p>
<p><code><br />
//Define fixed items<br />
#define ledPin 9 // LED connected to digital pin 9<br />
#define Mic1 0  // Mic (pot) for background volume connected to analog pin 0<br />
#define Mic2 1  // Mic (pot) for speech volume connected to analog pin 1<br />
#define alertDelta 100 // Minimum difference between background volume and speech volume required to trigger alert</p>
<p>//Initialize Variables<br />
int backgroundVolume = 0; // variable to store the read value<br />
int speechVolume = 0; // variable to store the read value</p>
<p>void setup()<br />
{<br />
 pinMode(ledPin, OUTPUT); // sets the pin as an output<br />
 Serial.begin(9600);<br />
}</p>
<p>void loop()<br />
{<br />
  readVolumes();<br />
  compareVolumes();<br />
}</p>
<p>void readVolumes() {<br />
  backgroundVolume = analogRead(Mic1); // reads input from the "background" mic<br />
  speechVolume = analogRead(Mic2); // reads input from the "Speech" mic<br />
  Serial.println(backgroundVolume, DEC);<br />
  Serial.println(speechVolume, DEC);<br />
}</p>
<p>void compareVolumes() {<br />
  if (speechVolume > (backgroundVolume + alertDelta)) {<br />
    alertRoutine();<br />
  }<br />
  else {<br />
    clearRoutine();<br />
  }<br />
}</p>
<p>void alertRoutine() {<br />
   Serial.println("Alert!");<br />
   analogWrite(ledPin, (speechVolume - backgroundVolume) / 4);<br />
}</p>
<p>void clearRoutine() {<br />
  analogWrite(ledPin, LOW);<br />
}<br />
</code></p>
<h2>Response and Feedback</h2>
<p>Faking both inputs and outputs, it was impossible to really test the device in use.  We faked up a little enclosure, however, and did a man-behind-the-curtain demo for the class, which was enough to see the potential and get some feedback.</p>
<p>On the input side, we clearly needed a microphone to work, and we determined that the speech one was the most important. The background mic could be faked a little longer. As for output, a number of suggestions came up, but Russ said something particularly intriguing about the essential nature of having the output map immediately and directly to the speech input itself. As we&#8217;d identified vibration as a candidate for that output, it was even more important that we find a way to differentiate that feedback from any of the other ways a phone might vibrate.</p>
<p>Both these things in mind, we moved ahead to the next revision.</p>
<h2>Second Iteration</h2>
<p>The second iteration began to reveal some of the things you can only tell by building and testing. We managed to wrangle microphone input into a range we were comfortable with, and added a vibrator motor as an output.</p>
<p>The first thing we realized we&#8217;d have to adjust was the analog output to the motor. Under a certain level, it simply wasn&#8217;t enough to start the vibrator motor moving, so we needed to account for that in the code.</p>
<p>The next big discovery was that we simply couldn&#8217;t get the microphone input to predictably trigger the alert. In the midst of yelling, it would stop, and it would trigger in the midst of normal speech. We even switched back to the LED as an output to make sure the motor wasn&#8217;t part of the problem. We soon realized the problem: speech is never at a continuous volume, the ups and downs are what enable our sounds to be shaped into words. Depending on where we &#8220;sampled&#8221; the &#8220;waveform,&#8221; we might hit a peak in regular speech, or a trough in loud speech. Instead, we&#8217;d need to look at, and respond to the envelope of the speech, not an individual sample. This meant building an average, and after a little searching we found a jumping-off point for writing code to do just that.</p>
<p>We were able to establish a flexible array, and respond to a rolling average of the speech volume. This smoothed out the bumps, and with some trial and error we were able to get output that wasn&#8217;t jumping all over, but was obviously and immediately related to the speech input. It was immediate enough that those who tried it knew inherently what was happening.</p>
<h2>Tweaks and Presentation</h2>
<p>The day before our presentation in class, new, better microphones with integrated amplifiers arrived, and we quickly integrated them into the project. This did not resolve a major remaining issue, however: every time an alert was triggered, a feedback loop began that all but ensured the device wouldn&#8217;t come back from the alert state.</p>
<p>With Rob&#8217;s help, we went through our code, and couldn&#8217;t find anything that would cause such an issue. All other possibilities excluded, we came to the conclusion that having the motor on the same power bus as the rest of the circuit was, when activated, causing a voltage drop large enough to frustrate the readings from the microphone. As a solution, we separated the power supply to the motor, which seemed to solve the problem.</p>
<p>Finally, to improve the artifact for presentation, we moved the components that didn&#8217;t absolutely need to be in the handset itself to an outboard breadboard connected with a ribbon &#8220;bus&#8221;. Additionally, we created a cleaner enclosure for the whole thing.</p>
<div id="attachment_158" class="wp-caption aligncenter" style="width: 610px"><a href="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/11/IMG_09641.JPG"><img src="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/11/IMG_09641-1024x768.jpg" alt="Presentation Mockup with outboard parts" title="Presentation Mockup with outboard parts" width="600" height="450" class="size-large wp-image-158" /></a><p class="wp-caption-text">Presentation Mockup with outboard parts</p></div>
<p>Everything held together for the in-house demo, and though the background volume level was still &#8220;faked&#8221; with a potentiometer and the motor vibration wasn&#8217;t as consistent or smooth as it might have been (or was in earlier testing) the concept still exhibited merit and seemed like something that could be successful (if potentially difficult to find a market for) if developed to its natural conclusion.</p>
<p>Code, as used in the final demo it below:<br />
<code><br />
//Define fixed items<br />
#define motorPin 9 // Vibrator motor connected to digital pin 9<br />
#define Mic1 0  // Mic (pot) for background volume connected to analog pin 0<br />
#define Mic2 1  // Mic for speech volume connected to analog pin 1<br />
#define alertDelta 5 // Minimum difference between background volume and speech volume required to trigger alert</p>
<p>//Initialize Audio Variables<br />
int backgroundVolume = 100; // variable to store the read value<br />
int rawMicInput = 0;<br />
int speechVolume = 0; // variable to store the read value</p>
<p>//Averaging Variables<br />
const int numReadings = 5;<br />
int readings[numReadings];	// the readings from the analog input<br />
int index = 0;			// the index of the current reading<br />
int total = 0;			// the running total<br />
int average = 0;		// the average</p>
<p>void setup()<br />
{<br />
  pinMode(motorPin, OUTPUT); // sets the pin as an output<br />
  Serial.begin(9600);</p>
<p>  for (int thisReading = 0; thisReading < numReadings; thisReading++) readings[thisReading] = 0;<br />
}</p>
<p>void loop()<br />
{<br />
  readVolumes();<br />
  processSpeechVolume();<br />
  averageRoutine();<br />
  compareVolumes();<br />
}</p>
<p>void readVolumes() {<br />
  backgroundVolume = analogRead(Mic1); // reads input from the "background" mic<br />
  rawMicInput = analogRead(Mic2); // reads input from the "Speech" mic<br />
  Serial.print(backgroundVolume, DEC);<br />
  Serial.print(" ");<br />
  Serial.println(average, DEC);<br />
  Serial.print(" ");<br />
}</p>
<p>// compare the volumes, and determine if an alert is required<br />
void compareVolumes() {<br />
  if (average > (backgroundVolume + alertDelta)) {<br />
    alertRoutine();<br />
  }<br />
  else {<br />
    clearRoutine();<br />
  }<br />
}</p>
<p>void alertRoutine() {<br />
  Serial.println("Alert!");<br />
  analogWrite(motorPin, ((average - backgroundVolume) / 2 ) + 17 );<br />
}</p>
<p>void processSpeechVolume() { // Normalize output to a positive 0 - 512 range<br />
  if (rawMicInput >= 512) {<br />
    speechVolume = rawMicInput - 512;<br />
  }<br />
  else {<br />
    speechVolume = 512 - rawMicInput;<br />
  }<br />
}</p>
<p>void clearRoutine() { // clear the signal to the motor<br />
  analogWrite(motorPin, LOW);<br />
}</p>
<p>void averageRoutine() { // place speechVolume into the array and average<br />
  // subtract the last reading:<br />
  total= total - readings[index];</p>
<p>  readings[index] = speechVolume;<br />
  // add the reading to the total:<br />
  total= total + readings[index];<br />
  // advance to the next position in the array:<br />
  index = index + 1;<br />
  // if we're at the end of the array...<br />
  if (index >= numReadings) {<br />
    // ...wrap around to the beginning:<br />
    index = 0;<br />
  }<br />
  // calculate the average:<br />
  average = total / numReadings;<br />
}<br />
</code></p>
<p>A quick video of SAVI in action:</p>
<p><object width="500" height="375"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=7670584&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=7670584&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="500" height="375"></embed></object>
<p><a href="http://vimeo.com/7670584">SAVI in Use</a> from <a href="http://vimeo.com/user1269179">Jeff Kirsch</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffkirsch.com/thoughtsandthings/2009/11/18/midterm-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programming Lab #2</title>
		<link>http://jeffkirsch.com/thoughtsandthings/2009/11/17/programming-lab-2/</link>
		<comments>http://jeffkirsch.com/thoughtsandthings/2009/11/17/programming-lab-2/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 18:57:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coursework]]></category>
		<category><![CDATA[Fundamentals of Physical Computing]]></category>

		<guid isPermaLink="false">http://jeffkirsch.com/thoughtsandthings/?p=133</guid>
		<description><![CDATA[This weekend, I finally looped back and got to the second programming lab. It&#8217;s the longest of the labs, and has a couple fairly challenging bits, so it seemed appropriate to wait until I had block of time to dedicate to it.
Part I: Drawing and Animation
The first part of the lab was pretty basic drawing [...]]]></description>
			<content:encoded><![CDATA[<p>This weekend, I finally looped back and got to the second programming lab. It&#8217;s the longest of the labs, and has a couple fairly challenging bits, so it seemed appropriate to wait until I had block of time to dedicate to it.</p>
<h2>Part I: Drawing and Animation</h2>
<p>The first part of the lab was pretty basic drawing and animation. Lessons in changing shape, color and positioning come together in later examples when we build a simple character out of multiple shapes and the animate it programatically. Anticipating the need for a robot in later examples, I created my character in a function from the start. Not too much to remark on here, so I&#8217;ll just link to the examples.</p>
<p><a href="http://jeffkirsch.com/files/programming_lab_2/shape/">Shape</a><br />
<a href="http://jeffkirsch.com/files/programming_lab_2/swatches/">Swatches</a><br />
<a href="http://jeffkirsch.com/files/programming_lab_2/character/">Character</a><br />
<a href="http://jeffkirsch.com/files/programming_lab_2/animation/">Animation</a></p>
<h2>Part II: Duplicating Examples</h2>
<p>Part two was significantly more challenging. We were asked to match four examples of increasing difficulty.</p>
<p><a href="http://jeffkirsch.com/files/programming_lab_2/square_lights/">Square Lights</a></p>
<p>The first example has four squares in a larger square. The square under the mouse is white, white the other three squares are black. I accomplished this by drawing four black squares, and then checking the current mouse position and redrawing a white square on top. Looking back at my code after having completed the who lab, it obvious that this could be accomplished much more efficiently. Maybe I&#8217;ll return to it if I get a moment.</p>
<p><a href="http://jeffkirsch.com/files/programming_lab_2/color_swap/">Color Swapper</a></p>
<p>In Color Swapper, we have a red rectangle and a blue rectangle. The red rectangle slowly becomes more and more blue as the blue rectangle becomes increasingly red, and vice versa. The end effect makes it appear that the colors are shifting from side to side.</p>
<p>Programmatically, that&#8217;s not too far off, and my solution has a &#8220;primary&#8221; variable as the red value for one rectangle and the blue for the other. The other color value is set by a &#8220;secondary&#8221; variable whose value is 255 minus the value of the primary. I add another variable to keep track of the direction we&#8217;re currently going in, and then decrement or increment the primary value accordingly. Color Swapper</p>
<p><a href="http://jeffkirsch.com/files/programming_lab_2/racetrack/">Racetrack</a></p>
<p>The Racetrack program produces a box that runs around the edge of a box. This actually struck me as one of the most straightforward of the set. I draw a box, and keep track of the direction in which it is moving, starting with it moving to the right. When I hit the edge of the frame, I change to moving it down, and so on. No collision detection here, I just use the &#8220;width&#8221; and &#8220;height&#8221; methods to determine to determine where to change direction. This allows the frame to be resized and the animation to continue functioning. Once again, this could be cleaned up, but in the interest of keeping moving, I left well enough alone on this one. Racetrack</p>
<p><a href="http://jeffkirsch.com/files/programming_lab_2/bounce/">Bounce</a></p>
<p>To my mind, this was by far the hardest example to approach, but eventually one of the simplest to implement. The example shows a box that begins at the top of the frame, and drops as if pulled by gravity toward the bottom. It bounces back up but, having lost some energy, does not return to its original height. After many bounces, it settles on the bottom of the frame.</p>
<p>I enlisted the help of my seriously math-y wife on this one, and between the two of us we managed to overthink the thing through several greatly overcomplicated versions, never getting it quite right. We set the box to change direction at a &#8220;top&#8221; and then lowered the &#8220;top&#8221; on each bounce. This made the box appear to &#8220;bounce&#8221; between two surfaces. We then tried to ease the top bounce&#8230; It was never quite right.</p>
<p>After a break, I decided to readdress the problem in a more realistic manner. I set out thinking I&#8217;d have to start from scratch, but we actually had created most of the necessary constructs already. I had a variable for velocity, set to 0 at the beginning of the program. I had a variable (held constant, actually) for acceleration, which set the box in motion to begin with. I had a test to tell if the box was at the bottom of the frame, and was able to change its direction. The only missing component was loss of velocity, which was easily implemented through a poorly-named &#8220;drag&#8221; constant. I added a quick line to decrement the velocity by that constant on each bounce, and the rest took care of itself.  Bounce</p>
<h2>Part III: Snowman Scene and Sharing Functions</h2>
<p>Having made it through the previous examples, the snowman scene was a nice break. This exercise is basically about abstracting code into functions, calling those functions with arguments, and sharing functions. As a general rule, I attempt to split things into functions, so this wasn&#8217;t anything too new.</p>
<p>A couple issues did arise, most notably that the scale() method effected not only size, but positioning. I worked around it for my custom function by internally adjusting the passed X and Y values, and simply adapted the stated X and Y values for my drawn snowmen.</p>
<p>To make things a little more interesting, I made the robot have flashing eyes (timed to alternate each second, by test if a given second was even or odd) and added Clint Beharry&#8217;s &#8220;Snow&#8221; function. <LINK></p>
<p><a href="http://jeffkirsch.com/files/programming_lab_2/snowman/">Snowman</a><br />
<a href="http://jeffkirsch.com/files/programming_lab_2/myfunction/">My Function</a><br />
<a href="http://jeffkirsch.com/files/programming_lab_2/sharedfunction/">Shared Function</a></p>
<p>Lab instructions available <a href="http://interactiondesign.sva.edu/classes/physicalcomputing/labs/lab-programming-2/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffkirsch.com/thoughtsandthings/2009/11/17/programming-lab-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Serial Lab</title>
		<link>http://jeffkirsch.com/thoughtsandthings/2009/11/11/serial-lab/</link>
		<comments>http://jeffkirsch.com/thoughtsandthings/2009/11/11/serial-lab/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 17:28:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coursework]]></category>
		<category><![CDATA[Fundamentals of Physical Computing]]></category>

		<guid isPermaLink="false">http://jeffkirsch.com/thoughtsandthings/?p=126</guid>
		<description><![CDATA[The serial lab was a quick one, but serial communication is somethingI&#8217;ll certainly be returning to in future projects.
Simple Serial Output
First, we wire up a simple potentiometer to an analog input, and pass the readings to Serial.print and from there, the computer.
In the serial monitor, the values are interpreted as ASCII characters.  I had [...]]]></description>
			<content:encoded><![CDATA[<p>The serial lab was a quick one, but serial communication is somethingI&#8217;ll certainly be returning to in future projects.</p>
<h2>Simple Serial Output</h2>
<p>First, we wire up a simple potentiometer to an analog input, and pass the readings to Serial.print and from there, the computer.</p>
<p>In the serial monitor, the values are interpreted as ASCII characters.  I had some fun trying to hit the &#8220;carriage return&#8221; character to break the flow of input up.</p>
<p>This code makes it all work:</p>
<p><code><br />
int analogPin = 0;<br />
int analogValue = 0;</p>
<p>void setup()<br />
{<br />
// start serial port at 9600 bps:<br />
Serial.begin(9600);<br />
}</p>
<p>void loop()<br />
{<br />
// read analog input, divide by 4 to make the range 0-255:<br />
analogValue = analogRead(analogPin);<br />
analogValue = analogValue / 4;<br />
Serial.print(analogValue, BYTE);<br />
// pause for 10 milliseconds:<br />
delay(10);<br />
}<br />
</code></p>
<h2>Simple Serial Output</h2>
<p>With a little more code in Processing, we&#8217;re able to visualize the serial input.  Somewhere along the line, I developed the strange habit of choosing the &#8220;cu&#8221; interface for the Arduino instead of &#8220;tty&#8221;, so I had to make the appropriate change to the code.  Otherwise, everything went smoothly. Code follows:</p>
<p><code><br />
/*<br />
Sensor Graphing Sketch</p>
<p>This sketch takes raw bytes from the serial port at 9600 baud and graphs them.</p>
<p>Created 20 April 2005<br />
Updated 5 August 2008<br />
by Tom Igoe<br />
Updated 2 November 2009<br />
by Rob Faludi<br />
*/</p>
<p>import processing.serial.*;</p>
<p>Serial myPort; // The serial port<br />
int graphXPos = 1; // the horizontal position of the graph:</p>
<p>void setup () {<br />
size(400, 300); // window size</p>
<p>// List all the available serial ports<br />
println(Serial.list());<br />
// I know that the fisrt port in the serial list on my mac<br />
// is usually my Arduino module, so I open Serial.list()[0].<br />
// Open whatever port is the one you're using.<br />
try { // attempt to open this port<br />
myPort = new Serial(this, Serial.list()[1], 9600);<br />
}<br />
// if the port cannot be opened, print an error message, then quit<br />
catch (Exception e) {<br />
println("** Error selecting serial port! **");<br />
println(" Have you attached your Arduino? Does your code specify the right port?");<br />
exit();<br />
}<br />
// set inital background:<br />
background(48,31,65);<br />
}<br />
void draw () {<br />
// nothing happens in draw. It all happens in SerialEvent()<br />
}</p>
<p>void serialEvent (Serial myPort) {<br />
// get the byte:<br />
int inByte = myPort.read();<br />
// print it:<br />
println(inByte);<br />
// set the drawing color. Pick a pretty color:<br />
stroke(123,128,158);<br />
// draw the line:<br />
line(graphXPos, height, graphXPos, height - inByte);</p>
<p>// at the edge of the screen, go back to the beginning:<br />
if (graphXPos >= width) {<br />
graphXPos = 0;<br />
// clear the screen:<br />
background(48,31,65);<br />
}<br />
else {<br />
// increment the horizontal position for the next reading:<br />
graphXPos++;<br />
}<br />
}<br />
</code></p>
<p>And that&#8217;s about that.  Full lab info available <a href="http://interactiondesign.sva.edu/classes/physicalcomputing/labs/lab-serial/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffkirsch.com/thoughtsandthings/2009/11/11/serial-lab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Motor Lab</title>
		<link>http://jeffkirsch.com/thoughtsandthings/2009/11/04/motor-lab/</link>
		<comments>http://jeffkirsch.com/thoughtsandthings/2009/11/04/motor-lab/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 18:34:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coursework]]></category>
		<category><![CDATA[Fundamentals of Physical Computing]]></category>

		<guid isPermaLink="false">http://jeffkirsch.com/thoughtsandthings/?p=120</guid>
		<description><![CDATA[Blinking lights and making sounds are great, but sometimes you just want to make things move. The Motors lab is a quick exercise in wiring and simple code that I&#8217;ve already used once between working through it and posting this write-up.
Basic speed control
The wiring for simple pulse-width modulated control of a motor is pretty basic, [...]]]></description>
			<content:encoded><![CDATA[<p>Blinking lights and making sounds are great, but sometimes you just want to make things move. The Motors lab is a quick exercise in wiring and simple code that I&#8217;ve already used once between working through it and posting this write-up.</p>
<h2>Basic speed control</h2>
<div id="attachment_121" class="wp-caption aligncenter" style="width: 610px"><a href="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/11/IMG_0925.JPG"><img src="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/11/IMG_0925-1024x768.jpg" alt="Basic motor setup" title="Basic Motor Setup" width="600" height="450" class="size-large wp-image-121" /></a><p class="wp-caption-text">Basic motor setup</p></div>
<p>The wiring for simple pulse-width modulated control of a motor is pretty basic, though a few additional precautions are necessary. First, rather than connecting directly to an Arduino analog output, we use that output to control a (TIP 120) transistor, allowing more voltage to go to the motor than the Arduino can handle. For the small motor in this example, 5v is more than enough. In addition, a diode is needed to prevent blowback from the motor. The &#8220;diodes&#8221; in our kit don&#8217;t seem to be directional, but using an LED instead seemed to make things work nicely.</p>
<p>As in so many other labs, a potentiometer provides analog input.</p>
<p>The following code is loaded to the Arduino:<br />
<code><br />
int motorPin = 9;      // motor connected to digital pin 9<br />
int analogPin = 0;   // potentiometer connected to analog pin 0<br />
int val = 0;         // variable to store the read value</p>
<p>void setup()<br />
{<br />
  pinMode(motorPin, OUTPUT);   // sets the pin as output<br />
}</p>
<p>void loop()<br />
{<br />
  val = analogRead(analogPin);   // read the input pin<br />
  analogWrite(motorPin, val / 4);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255<br />
}<br />
</code></p>
<p>And the results:</p>
<p><object width="500" height="375"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=7437280&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=7437280&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="500" height="375"></embed></object>
<p><a href="http://vimeo.com/7437280">Basic Motor Speed Control</a> from <a href="http://vimeo.com/user1269179">Jeff Kirsch</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<h2>Controlling direction</h2>
<p>Controlling the direction of a motor is as simple as changing the direction of current. That, however, is easier said than done.  Basically, you need a set of electronically controlled relays to force current across the motor in one direction, or the other.</p>
<p>Luckily, such a setup exists, in one package. This H-Bridge chip actually allows directional control of two motors. In our setup, a switch is used as a digital input for the Arduino; this is then translated into output to two legs of the H-bridge, causing current to the motor to reverse direction. The wiring is pretty straightforward once you see what&#8217;s going on; the results are below.</p>
<div id="attachment_122" class="wp-caption aligncenter" style="width: 610px"><a href="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/11/IMG_0927.JPG"><img src="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/11/IMG_0927-1024x768.jpg" alt="Directional motor control" title="Directional motor control" width="600" height="450" class="size-large wp-image-122" /></a><p class="wp-caption-text">Directional motor control</p></div>
<p><object width="500" height="375"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=7437521&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=7437521&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="500" height="375"></embed></object>
<p><a href="http://vimeo.com/7437521">Directional Motor</a> from <a href="http://vimeo.com/user1269179">Jeff Kirsch</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Code follows:</p>
<p><code><br />
const int switchPin = 2;    // switch input<br />
const int motor1Pin = 3;    // H-bridge leg 1 (pin 3, 1A)<br />
const int motor2Pin = 7;    // H-bridge leg 2 (pin 7, 2A)<br />
const int enablePin = 9;    // H-bridge enable pin<br />
const int ledPin = 13;      // LED </p>
<p>void setup() {<br />
  // set the switch as an input:<br />
  pinMode(switchPin, INPUT); </p>
<p>  // set all the other pins you're using as outputs:<br />
  pinMode(motor1Pin, OUTPUT);<br />
  pinMode(motor2Pin, OUTPUT);<br />
  pinMode(enablePin, OUTPUT);<br />
  pinMode(ledPin, OUTPUT);</p>
<p>  // set enablePin high so that motor can turn on:<br />
  digitalWrite(enablePin, HIGH); </p>
<p>  // blink the LED 3 times. This should happen only once.<br />
  // if you see the LED blink three times, it means that the module<br />
  // reset itself,. probably because the motor caused a brownout<br />
  // or a short.<br />
  blink(ledPin, 3, 100);<br />
}</p>
<p>void loop() {<br />
  // if the switch is high, motor will turn on one direction:<br />
  if (digitalRead(switchPin) == HIGH) {<br />
    digitalWrite(motor1Pin, LOW);   // set leg 1 of the H-bridge low<br />
    digitalWrite(motor2Pin, HIGH);  // set leg 2 of the H-bridge high<br />
  }<br />
  // if the switch is low, motor will turn in the other direction:<br />
  else {<br />
    digitalWrite(motor1Pin, HIGH);  // set leg 1 of the H-bridge high<br />
    digitalWrite(motor2Pin, LOW);   // set leg 2 of the H-bridge low<br />
  }<br />
}</p>
<p>/*<br />
  blinks an LED<br />
 */<br />
void blink(int whatPin, int howManyTimes, int milliSecs) {<br />
  int i = 0;<br />
  for ( i = 0; i < howManyTimes; i++) {<br />
    digitalWrite(whatPin, HIGH);<br />
    delay(milliSecs/2);<br />
    digitalWrite(whatPin, LOW);<br />
    delay(milliSecs/2);<br />
  }<br />
}</p>
<p></code></p>
<p>Lab instructions available <a href="http://interactiondesign.sva.edu/classes/physicalcomputing/labs/lab-motors/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffkirsch.com/thoughtsandthings/2009/11/04/motor-lab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Analog Output Lab</title>
		<link>http://jeffkirsch.com/thoughtsandthings/2009/10/15/analog-output-lab/</link>
		<comments>http://jeffkirsch.com/thoughtsandthings/2009/10/15/analog-output-lab/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 15:37:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coursework]]></category>
		<category><![CDATA[Fundamentals of Physical Computing]]></category>

		<guid isPermaLink="false">http://jeffkirsch.com/thoughtsandthings/?p=95</guid>
		<description><![CDATA[In the analog output lab, we&#8217;re learning to make use of code libraries to control servos and speakers.
Controlling a servo
The first project involves a simple servo motor, connected to power, ground and an Arduino PWM pin (digital 9, in this case), and a potentiometer, connected to power, ground, and an Arduino analog input pin.
The code [...]]]></description>
			<content:encoded><![CDATA[<p>In the analog output lab, we&#8217;re learning to make use of code libraries to control servos and speakers.</p>
<h2>Controlling a servo</h2>
<p>The first project involves a simple servo motor, connected to power, ground and an Arduino PWM pin (digital 9, in this case), and a potentiometer, connected to power, ground, and an Arduino analog input pin.</p>
<p>The code below is loaded on the Arduino. It reads and scales input from the potentiometer, and uses those values to control servo position through the servo library.</p>
<p><code><br />
// Controlling a servo position using a potentiometer (variable resistor)<br />
// by Michal Rinott</code></p>
<p><code> </code></p>
<p><code>#include &lt;Servo.h&gt;</p>
<p>Servo myservo; // create servo object to control a servo</p>
<p>int potpin = 0; // analog pin used to connect the potentiometer<br />
int val; // variable to read the value from the analog pin</p>
<p>void setup()<br />
{<br />
myservo.attach(9); // attaches the servo on pin 9 to the servo object<br />
}</p>
<p></code></p>
<p><code>void loop()<br />
{<br />
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)<br />
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 179)<br />
myservo.write(val); // sets the servo position according to the scaled value<br />
delay(15); // waits for the servo to get there<br />
}<br />
</code></p>
<p>The results can be seen below:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="375" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=7067590&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="500" height="375" src="http://vimeo.com/moogaloop.swf?clip_id=7067590&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/7067590">Servo (Full Range)</a> from <a href="http://vimeo.com/user1269179">Jeff Kirsch</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>By changing the mapping from this:</p>
<p><code><br />
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 179)<br />
</code></p>
<p>to this:</p>
<p><code><br />
val = map(val, 0, 1023, 0, 90); // scale it to use it with the servo (value between 0 and 90)<br />
</code></p>
<p>we&#8217;re able to make the full range of the potentiometer only control movement between 0 and 90 degrees, as shown in this second video.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="375" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=7067798&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="500" height="375" src="http://vimeo.com/moogaloop.swf?clip_id=7067798&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/7067798">Servo (Partial Range)</a> from <a href="http://vimeo.com/user1269179">Jeff Kirsch</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<h2>Controlling a speaker</h2>
<p>Using another library, the Tone library, we&#8217;re able to easily produce audio from a speaker connected to one of the Arduino&#8217;s digital output pins. Analog input is provided by the same potentiometer as before. The code and results are below.</p>
<p><code><br />
#include &lt;Tone.h&gt;<br />
Tone mytone; // declare a tone name</code></p>
<p><code> </code></p>
<p><code>void setup() {<br />
// initialize the tone<br />
mytone.begin(8);<br />
}</p>
<p></code></p>
<p><code>void loop() {<br />
// read the analog input<br />
int inVar = analogRead(0);<br />
// map the input to a frequency range between 200 and 2000 Hz<br />
int note = map(inVar, 0, 1023, 200, 2000);<br />
// play the note<br />
mytone.play(note);<br />
}<br />
</code></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="375" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=7067841&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="500" height="375" src="http://vimeo.com/moogaloop.swf?clip_id=7067841&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/7067841">Arduino Synth</a> from <a href="http://vimeo.com/user1269179">Jeff Kirsch</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<h2>Create something unique</h2>
<p>At first, I wasn&#8217;t sure where to go with this part of the assignment; just a bit of a brain freeze moment. I decided to use a flex sensor in a voltage divider circuit as an input, put wasn&#8217;t sure what I could do with it that wouldn&#8217;t be boring.</p>
<p>Then, all it once, it dawned on me. I&#8217;d construct a simple tone-matching game.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="375" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=7063494&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="500" height="375" src="http://vimeo.com/moogaloop.swf?clip_id=7063494&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/7063494">Tone Game Tour</a> from <a href="http://vimeo.com/user1269179">Jeff Kirsch</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>I hooked a second speaker up to the Arduino and wired in the flex sensor, plus a simple momentary push-button switch. The script below does all the work, producing a randomly-generated pitch from one speaker, while controlling the pitch of another tone based on the input from the flex sensor.  A simple boolean test determines if the note controlled by the flex sensor is within +/- 5 Hz of the target note, and if so plays a little &#8220;success&#8221; progression and selects a new target pitch.</p>
<p><code><br />
#include &lt;Tone.h&gt;<br />
//defines "BUTTON" as "13"<br />
#define BUTTON 13<br />
Tone mytone; // declare a tone name<br />
Tone mytone2; // declare a second tone name<br />
//create integer variable "randTone" to hold random tone values and initilize to 440 Hz<br />
int randTone = 440;</code></p>
<p><code> </code></p>
<p><code>void setup() {<br />
// initialize the tone controlled by the flex sensor<br />
mytone.begin(8);<br />
//initialize the randomly generated "target" tone<br />
mytone2.begin(7);<br />
//begin serial connection for debugging<br />
Serial.begin(9600);<br />
//set BUTTON as an input<br />
pinMode(BUTTON, INPUT);  // and BUTTON is an input</p>
<p>}</p>
<p>void loop() {</p>
<p>//run generateRandTone() when button is pressed<br />
if (digitalRead(BUTTON) == HIGH) {<br />
generateRandTone();<br />
}<br />
// read the flex sensor input<br />
int inVar = analogRead(0);<br />
// map the input to a frequency range between 200 and 2000 Hz<br />
int note = map(inVar, 150, 552, 200, 2000);<br />
// play the note<br />
mytone.play(note);<br />
//play the target note<br />
mytone2.play(randTone);<br />
//print the note value to the serial monitor<br />
Serial.println(note, DEC);<br />
//print the target value to the serial monitor<br />
Serial.println(randTone, DEC);<br />
//test for a match. Returns "True" if note is +/- 5Hz away from the target tone.<br />
if ((randTone &gt; note - 5) &amp;&amp; (randTone &lt; note + 5)) {<br />
successRoutine();<br />
}<br />
//Delay ensures note must be held to win, and note to "step"<br />
delay(100);<br />
}</p>
<p>//This function sets the variable randTone to a "random" value between 250 and 1900<br />
void generateRandTone() {<br />
randTone = random(250, 1900);<br />
}</p>
<p></code></p>
<p><code>//This function runs when the input note is close enough to match the target note. It plays a quick melody based on the target note, then calls generateRandTone() to produce a new target note for the next round.<br />
void successRoutine() {<br />
mytone.play(randTone);<br />
mytone2.play(randTone);<br />
delay(500);<br />
mytone.play(randTone / 2);<br />
mytone2.play(randTone / 2);<br />
delay(1000);<br />
mytone.play(randTone);<br />
mytone2.play(randTone);<br />
delay(1000);<br />
mytone.play(randTone * 2);<br />
mytone2.play(randTone * 2);<br />
delay(1000);<br />
mytone.play(randTone);<br />
mytone2.play(randTone);<br />
delay(1500);<br />
generateRandTone();<br />
}<br />
</code></p>
<p>A video of the game in action: (Warning, the audio is very, very annoying.)<br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="375" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=7063748&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="500" height="375" src="http://vimeo.com/moogaloop.swf?clip_id=7063748&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/7063748">Tone Game Demo</a> from <a href="http://vimeo.com/user1269179">Jeff Kirsch</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Full instructions for the lab available <a href="http://interactiondesign.sva.edu/classes/physicalcomputing/labs/lab-analog-output/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffkirsch.com/thoughtsandthings/2009/10/15/analog-output-lab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Analog Input Lab</title>
		<link>http://jeffkirsch.com/thoughtsandthings/2009/09/28/analog-input-lab/</link>
		<comments>http://jeffkirsch.com/thoughtsandthings/2009/09/28/analog-input-lab/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 02:45:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coursework]]></category>
		<category><![CDATA[Fundamentals of Physical Computing]]></category>

		<guid isPermaLink="false">http://jeffkirsch.com/thoughtsandthings/?p=78</guid>
		<description><![CDATA[In the analog input lab, we look at variable resistors, and the ability to read their changes in voltage through the Arduino&#8217;s analog inputs.
Using a simple variable resistor
The basic setup involves a potentiometer, which serves as a voltage divider without any additional components. The center pole of the potentiometer is run to analog input pin [...]]]></description>
			<content:encoded><![CDATA[<p>In the analog input lab, we look at variable resistors, and the ability to read their changes in voltage through the Arduino&#8217;s analog inputs.</p>
<h2>Using a simple variable resistor</h2>
<p>The basic setup involves a potentiometer, which serves as a voltage divider without any additional components. The center pole of the potentiometer is run to analog input pin 3 on the Arduino, while the other poles run to power and ground. An LED (with a 330 Ohm resistor) is attached to digital pin 9 and ground to serve as our output.</p>
<p>The following code is loaded to the Arduino:<br />
<code><br />
int ledPin = 9;      // LED connected to digital pin 9<br />
int analogPin = 3;   // potentiometer connected to analog pin 3<br />
int val = 0;         // variable to store the read value</code></p>
<p><code>void setup()<br />
{<br />
pinMode(ledPin, OUTPUT);   // sets the pin as output<br />
}</p>
<p></code></p>
<p><code>void loop()<br />
{<br />
val = analogRead(analogPin);   // read the input pin<br />
analogWrite(ledPin, val / 4);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255<br />
}<br />
</code></p>
<p>The Arduino reads the voltage coming off of the potentiometer (reading 1023 for 5v, and 0 for 0 volts) and divides it by 4 to get an 8-bit value for pulse-width modulated output to the LED.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="375" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=6806906&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="500" height="375" src="http://vimeo.com/moogaloop.swf?clip_id=6806906&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/6806906">Adjusting LED brightness with Arduino</a> from <a href="http://vimeo.com/user1269179">Jeff Kirsch</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>The code also prints the values coming off pin 3 to the serial monitor:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="375" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=6806938&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="500" height="375" src="http://vimeo.com/moogaloop.swf?clip_id=6806938&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/6806938">Serial output of potentiometer readings</a> from <a href="http://vimeo.com/user1269179">Jeff Kirsch</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<h2>Sensing temperature</h2>
<p>The next step is replacing the potentiometer with another form of variable resistor (and an appropriate fixed resistor to complete the voltage divider). I chose a thermistor, and started with a 10k fixed resistor.</p>
<p>Squeezing with my fingers, I was only able to raise the temperature a few degrees, but there was clearly a change in voltages. The voltage drop across the thermistor read between 4.45 volts when &#8220;resting&#8221; and 4.38 volts when held, with appropriate changes in voltage measured across the fixed resistor.</p>
<p>Switching to a 1k fixed resistor gave a more even division of voltage at ambient temperatures, with the thermistor ranging between 2.45v baseline and 2.14v when held, with the fixed resistor taking on the balance of 5 volts in each case. Serial output reflected this with reads in the 500+ range.</p>
<h2>Invent something</h2>
<p>For the last part of the lab, we&#8217;re asked to make something with an analog input.</p>
<p>A raid of another institution&#8217;s computer store brought a very interesting component to my attention, the <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=9269">Sparkfun ADXL335</a> Triple Axis Accelerometer.  Some quick research revealed that this breakout board outputs voltage between 0 and 5 volts from each of 3 pins depending on its orientation. That meant that I&#8217;d need three analog outputs as well. But what has three components with values between 0 and 255? Why, the RGB color space, of course. Luckily, the computer store also carried a <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=9264">diffused Triple Output RGB LED</a>.</p>
<p>To start with, however, I simply soldered a header onto the accelerometer, hooked it up to the Arduino (with the help of this <a href="http://www.arduino.cc/en/Tutorial/ADXL3xx">tutorial</a>), and watched the values roll into the serial monitor.<br />
<div id="attachment_88" class="wp-caption aligncenter" style="width: 610px"><a href="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/09/IMG_0116.JPG"><img src="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/09/IMG_0116-1024x768.jpg" alt="ADXL335 Accelerometer soldered to a 6-pin header." title="ADXL335 Accelerometer " width="600" height="450" class="size-large wp-image-88" /></a><p class="wp-caption-text">ADXL335 Accelerometer soldered to a 6-pin header.</p></div></p>
<p>I then tweaked the code to map the input to three channels of PWM output and hooked up a few LEDs for a quick test.</p>
<p><object width="500" height="375"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=6807516&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=6807516&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="500" height="375"></embed></object>
<p><a href="http://vimeo.com/6807516">Accelerometer-controlled LEDs</a> from <a href="http://vimeo.com/user1269179">Jeff Kirsch</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>With that all working, and having gotten past some common cathode confusion, I wired up the RGD LED, tweaked the code, and gave it a try.</p>
<p><object width="500" height="375"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=6787881&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=6787881&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="500" height="375"></embed></object>
<p><a href="http://vimeo.com/6787881">Arduino + Accelerometer + RGB LED</a> from <a href="http://vimeo.com/user1269179">Jeff Kirsch</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>And there you have it&#8230; real-time color mixing based on orientation. My lovely fiancee Cara assisted with the demo.</p>
<p>In my excitement, I left the outputs connected to the closest pins of the LED, so in this video, the color channels don&#8217;t map to the axes in the correct order. In the code included below, X is blue, Y is red and Z is green.<br />
<code><br />
/*<br />
Created September 27 2009 by Jeff Kirsch</p>
<p>Translates 3 axis motion into color via a triple input LED.</p>
<p>Based on http://www.arduino.cc/en/Tutorial/ADXL3xx by David A. Mellis<br />
modified by Tom Igoe </p>
<p>  The circuit:<br />
  analog 0: accelerometer self test<br />
  analog 1: z-axis<br />
  analog 2: y-axis<br />
  analog 3: x-axis<br />
  analog 4: ground<br />
  analog 5: vcc</p>
<p>  Digital pins 9, 10 and 11 drive blue, red and green legs<br />
  */<br />
 // these constants describe the pins. They won't change:<br />
 const int groundpin = 18;             // analog input pin 4 -- ground<br />
 const int powerpin = 19;              // analog input pin 5 -- voltage<br />
 const int xpin = 3;                   // x-axis of the accelerometer<br />
 const int ypin = 2;                   // y-axis<br />
 const int zpin = 1;                   // z-axis (only on 3-axis models)<br />
 const int blueLed = 9;                // output pin for blue LED<br />
 const int redLed = 10;                // output pin for red LED<br />
 const int greenLed = 11;              // output pin for green LED<br />
 void setup()<br />
 {</p>
<p>   // Provide ground and power by using the analog inputs as normal<br />
   // digital pins.  This makes it possible to directly connect the<br />
   // breakout board to the Arduino.  If you use the normal 5V and<br />
   // GND pins on the Arduino, you can remove these lines.<br />
   pinMode(groundpin, OUTPUT);<br />
   pinMode(powerpin, OUTPUT);<br />
   digitalWrite(groundpin, LOW);<br />
   digitalWrite(powerpin, HIGH);</p>
<p>   //sets pins for LEDs as outputs<br />
   pinMode(blueLed, OUTPUT);<br />
   pinMode(redLed, OUTPUT);<br />
   pinMode(greenLed, OUTPUT);<br />
 }<br />
 void loop()<br />
 {<br />
   //run tilitToLight function for each axis<br />
   tiltToLight(xpin, blueLed);<br />
   tiltToLight(ypin, redLed);<br />
   tiltToLight(zpin, greenLed);</p>
<p> }</p>
<p> void tiltToLight(int readFrom, int writeTo){<br />
   //set readVal to the input from the accelerometer, minus 400<br />
   //for this model accelerometer, raw input minus 400 yields values roughly between 0 and 255<br />
  int readVal = (analogRead(readFrom) - 400);</p>
<p>  //check for out-of-range values<br />
  if (readVal < 0) {<br />
    readVal = 0;<br />
  }<br />
  else if(readVal > 255) {<br />
   readVal = 255;<br />
  }</p>
<p>  //write the modified input from the specificed axis of the accelerometer to the appropriate output pin<br />
  analogWrite(writeTo, (readVal));</p>
<p> }<br />
</code></p>
<p>Thanks to <a href="http://ericstonge.com">Eric</a> for his help in getting the input reading and output writing into a nice reusable function.</p>
<p>Lab instructions available <a href="http://interactiondesign.sva.edu/classes/physicalcomputing/labs/lab-analog-input/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffkirsch.com/thoughtsandthings/2009/09/28/analog-input-lab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Electronics Lab</title>
		<link>http://jeffkirsch.com/thoughtsandthings/2009/09/20/electronics-lab/</link>
		<comments>http://jeffkirsch.com/thoughtsandthings/2009/09/20/electronics-lab/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 22:20:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coursework]]></category>
		<category><![CDATA[Fundamentals of Physical Computing]]></category>

		<guid isPermaLink="false">http://jeffkirsch.com/thoughtsandthings/?p=58</guid>
		<description><![CDATA[In the electronics lab, we&#8217;re learning about different ways of hooking up simple electronic components. This lab doesn&#8217;t require the Arduino, which also means we can&#8217;t make use of its integrated power regulator. Instead, we&#8217;ll need to solder up a power jack, and connect it to to the breadboard via a 5-volt power regulator (the [...]]]></description>
			<content:encoded><![CDATA[<p>In the electronics lab, we&#8217;re learning about different ways of hooking up simple electronic components. This lab doesn&#8217;t require the Arduino, which also means we can&#8217;t make use of its integrated power regulator. Instead, we&#8217;ll need to solder up a power jack, and connect it to to the breadboard via a 5-volt power regulator (the power supply outputs 12v DC).<br />
<div id="attachment_59" class="wp-caption aligncenter" style="width: 610px"><a href="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/09/IMG_0081.JPG"><img src="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/09/IMG_0081-1024x768.jpg" alt="Soldering the power jack" title="Soldering the power jack" width="600" height="450" class="size-large wp-image-59" /></a><p class="wp-caption-text">Soldering the power jack</p></div><br />
<div id="attachment_61" class="wp-caption aligncenter" style="width: 610px"><a href="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/09/IMG_0083.JPG"><img src="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/09/IMG_0083-1024x768.jpg" alt="Reverse of the 7805 5v DC regulator" title="Power regulator" width="600" height="450" class="size-large wp-image-61" /></a><p class="wp-caption-text">Reverse of the 7805 5v DC regulator</p></div></p>
<p>With power flowing to the rails on either side of the breadboard, we&#8217;re able to use the multimeter to confirm a reading of 5.01v.</p>
<p>Next, we use a momentary switch, LED and a 330 ohm resistor to build a circuit.<br />
<div id="attachment_63" class="wp-caption aligncenter" style="width: 610px"><a href="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/09/IMG_0088.JPG"><img src="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/09/IMG_0088-1024x768.jpg" alt="A simple circuit" title="Simple circuit" width="600" height="450" class="size-large wp-image-63" /></a><p class="wp-caption-text">A simple circuit</p></div></p>
<p>The voltage as measured at various points on the circuit is as follows:</p>
<ul>
<li>Across switch (open): 3.41v</li>
<li>Across switch (closed): 0v</li>
<li>Across LED (open): 0v</li>
<li>Across LED (closed): 2.02v</li>
<li>Across resistor (open): 0v</li>
<li>Across resistor (closed): 1.91v</li>
</ul>
<p>This makes sense. When the switch is open, no power flows to the LED or resistor. When the switch is closed, power flows to those components, and voltage drops across each. The closed switch provides no resistance, so there is no voltage drop across it.</p>
<p>The next circuit is simply two LEDs in series. Voltage drop across various components is as follows:</p>
<ul>
<li>+ to LED1+: 0v</li>
<li>LED1+ to LED1-: 2.69v</li>
<li>LED2+ to LED2-: 2.40v</li>
<li>LED1+ to LED2-: 5.01v</li>
</ul>
<p>As the two LEDs provide adequate resistance (5.01v drop across the circuit), there&#8217;s no need for any additional components.</p>
<div id="attachment_68" class="wp-caption aligncenter" style="width: 610px"><a href="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/09/IMG_0091.JPG"><img src="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/09/IMG_0091-1024x768.jpg" alt="It really did read 5.01v when I pressed the shutter" title="Two LEDs in Series" width="600" height="450" class="size-large wp-image-68" /></a><p class="wp-caption-text">It really did read 5.01v when I pressed the shutter</p></div>
<p>The next step is to create a parallel circuit.  For this, we&#8217;ll use three LEDs, and bring the resistor back in. Since the LEDs are in parallel, the voltage drop over each is the same (3.68v). Measuring current with the multimeter in series, we get a reading of 8.3 mA.</p>
<div id="attachment_72" class="wp-caption aligncenter" style="width: 610px"><a href="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/09/IMG_00921.JPG"><img src="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/09/IMG_00921-1024x768.jpg" alt="LEDs in parallel" title="LEDs in parallel" width="600" height="450" class="size-large wp-image-72" /></a><p class="wp-caption-text">LEDs in parallel</p></div>
<p>Finally, we solder leads onto a 10k potentiometer, and connect that to a single LED and a 330 ohm resistor. Adjusting the resistance increases or decreases the voltage going into the circuit.</p>
<p><object width="500" height="375"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=6672408&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=6672408&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="500" height="375"></embed></object>
<p><a href="http://vimeo.com/6672408">Varying resistance in a circuit</a> from <a href="http://vimeo.com/user1269179">Jeff Kirsch</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>The voltage ranges from 0v to 3.8v. The LED doesn&#8217;t come on at all until the voltage hits 1.72v, and gradually brightens until &#8220;snapping&#8221; to full brightness at 3.69v.</p>
<p>And that&#8217;s about it. Full procedure is available <a href="http://interactiondesign.sva.edu/classes/physicalcomputing/labs/lab-electronics/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffkirsch.com/thoughtsandthings/2009/09/20/electronics-lab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Imagining Physical Computing</title>
		<link>http://jeffkirsch.com/thoughtsandthings/2009/09/16/imagining-physical-computing/</link>
		<comments>http://jeffkirsch.com/thoughtsandthings/2009/09/16/imagining-physical-computing/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 17:31:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Fundamentals of Physical Computing]]></category>

		<guid isPermaLink="false">http://jeffkirsch.com/thoughtsandthings/?p=30</guid>
		<description><![CDATA[Outside of doing a bunch of soldering and wiring and code tweaking, we&#8217;ve been asked to imagine applications for physical computing that go beyond the basic tools we currently have access to as students, and even beyond what&#8217;s commercially available today.
The idea for this project stems from some thinking I was doing about how we, [...]]]></description>
			<content:encoded><![CDATA[<p>Outside of doing a bunch of soldering and wiring and code tweaking, we&#8217;ve been asked to imagine applications for physical computing that go beyond the basic tools we currently have access to as students, and even beyond what&#8217;s commercially available today.</p>
<p>The idea for this project stems from some thinking I was doing about how we, as humans, communicate. Despite cellphones, text messaging, email, teleconferencing and the like, there&#8217;s clearly a tremendous amount of value to physical contact, in all its forms, with other human beings. This is true not just socially but commercially, as evidenced by the continued need for business travel. Nothing closes a deal quite like a handshake. And nothing starts one quite like a handshake, either.</p>
<p>A handshake in itself can tell you a lot about a person. For me, an awkward one isn&#8217;t usually a deal-breaker, but it definitely does effect my impression of what comes next.</p>
<p>That initial handshake is usually followed by an exchange of ideas and information, to put it about as dryly as possible.  If any of it seems to be leading anywhere, there&#8217;s usually a swapping of information about how to get in touch in the future. Maybe a business card, maybe a phone number on a napkin.</p>
<p>For an increasingly large number of people, the contact information they collect is stored digitally, but it&#8217;s rarely gathered this way, despite various <a href="http://www.youtube.com/watch?v=6bcTc8e2-6U">attempts</a> to make it catch on.</p>
<p>I&#8217;d propose that there are a number of reasons for this.  First, most solutions are fairly clunky, require both parties to own the same hardware and software, and simply don&#8217;t provide any real compelling advantage over more traditional methods. Second, there&#8217;s a physicality inherent in the handshake and the card-pass that has some real value. (Admittedly, the latest generation of smart phones provides some <a href="http://www.bumptechnologies.com/">examples</a> of attempts to add physicality back into the equation, but they suffer from many of the same downsides as earlier efforts.)</p>
<p>What I&#8217;m envisioning is a digital exchange of data that happens silently in the background of a handshake. RFID-enabled rings transmit a unique wearer identifiers to each other. This exchange is only triggered when the rings are in close proximity. Contact information, including location and time of first meeting, is instantly sent to each party&#8217;s address book of choice. If this isn&#8217;t a first meeting, information is updated and appended as needed.</p>
<p>Now, there are obviously quite a few leaps being taken here, but hey, that&#8217;s the point of the assignment. To make this work, and avoid the problems of the earlier digital solutions plus a boatload of new ones, I&#8217;m assuming a few things are true.  A non-exhaustive list follows.</p>
<ul>
<li>Battery life is not an issue</li>
<li>There are well developed, open standards for RFID</li>
<li>Various manufacturers use these standards</li>
<li>There are well developed, open standards for storing and transmitting contact information</li>
<li>Security considerations have been considered</li>
<li>Internet access is ubiquitous</li>
</ul>
<p>With such a system in place, business cards could become a thing of the past, as a seamless transmission of information directly to the place it was needed would occur as easily as humans have greeted each other for centuries. The information transmitted could also be context-specific, eg. when you&#8217;re out at a bar, your personal information might be favored over your work number and website.</p>
<p>It isn&#8217;t very much of a leap to consider a possible ecology of these sorts of devices, transmitting different information to each other based on the pairings. A ring in proximity to another device embedded in the back of a shirt might transmit data commiserate with a hug. A locket worn around the neck would likely share even more personal information. In this way, the different levels of digital data that each person maintains are mapped to our physical interactions with others in the real world.</p>
<p>I&#8217;m not saying this is something anyone would ever buy, or even want, but again, that&#8217;s not the point of the assignment. We&#8217;ve simply been asked to consider the ways that physical computing could effect our lives and interactions, and I&#8217;m perpetually fascinated with the space where the digital world and the physical world interact.</p>
<p>For the purposes of my in-class presentation, I&#8217;ve put together a much lower-tech prototype to mock up the interaction.  I wouldn&#8217;t want all that soldering to go to waste.</p>
<p>Basically, I use an aluminum foil ring and bracelet to close a circuit and tell the Arduino to run a simple function. This function makes some fake &#8220;progress&#8221; lights turn on, and then sends hard-coded &#8220;contact&#8221; information to a console on a computer screen.  It&#8217;s not much, but it helps illustrate the concept and allows me to show off my foil-jewelry making skills.</p>
<p><object width="500" height="375"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=6611661&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=6611661&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="500" height="375"></embed></object>
<p><a href="http://vimeo.com/6611661">Imagined Physical Computing demo</a> from <a href="http://vimeo.com/user1269179">Jeff Kirsch</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>The basic setup is shown below, sans all-important human participants.  I&#8217;ll get a circuit diagram up as soon as I get a chance.</p>
<div id="attachment_37" class="wp-caption aligncenter" style="width: 610px"><a href="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/09/Full-setup.jpg"><img class="size-large wp-image-37" title="Physical components" src="http://jeffkirsch.com/thoughtsandthings/wp-content/uploads/2009/09/Full-setup-1024x768.jpg" alt="Quickly prototyped board for use in class" width="600" height="450" /></a><p class="wp-caption-text">Quickly prototyped board for use in class</p></div>
<p>The code running on the Arduino, tweaked almost beyond recognition, but based on a simple <a href="http://cdn.makezine.com/make/books/getstartedarduino/eg/Example_02.txt">example</a> from Getting Started with Arduino is below. It&#8217;s scarcely as clean, efficient or well-commented as it should be, but it works for a quick-and-dirty demo.</p>
<p><code>#define DEL 100<br />
#define LED1 10<br />
#define LED2 11<br />
#define LED3 12<br />
#define LED4 13<br />
// the pin for the LED<br />
#define BUTTON 7<br />
#define BUTTON2 8<br />
int val = 0;<br />
int val2 = 0;</code></p>
<p><code>void setup() {<br />
pinMode(LED1, OUTPUT);   // tell Arduino LED1 is an output<br />
pinMode(LED2, OUTPUT);   // tell Arduino LED2 is an output<br />
pinMode(LED3, OUTPUT);   // tell Arduino LED3 is an output<br />
pinMode(LED4, OUTPUT);   // tell Arduino LED4 is an output<br />
pinMode(BUTTON, INPUT); // and BUTTON is an input<br />
pinMode(BUTTON2, INPUT); // and BUTTON is an input<br />
Serial.begin(9600);           // set up Serial library at 9600 bps<br />
}</p>
<p>void loop(){<br />
val = digitalRead(BUTTON);<br />
val2 = digitalRead(BUTTON2);</p>
<p>if (val == HIGH) {<br />
myInfoFunction(1);<br />
} else if (val2 == HIGH) {<br />
myInfoFunction(2);<br />
}<br />
}</p>
<p>void myInfoFunction(int which) {<br />
myProgressFunction();<br />
if (which == 1) {<br />
Serial.println("Rob Faludi rob@example.com 212-555-1212 - SVA IxD Space - September 16, 2009 - 3:02 PM");<br />
}</p>
<p>else if (which == 2) {<br />
Serial.println("Carmen Dukes carmen@example.com 212-555-1234 - SVA IxD Space - September 16, 2009 - 3:00 PM");<br />
}</p>
<p>else {<br />
delay(1);<br />
}</p>
<p>myResetFunction();<br />
}</p>
<p>void myProgressFunction() {<br />
digitalWrite(LED1, HIGH);<br />
delay(DEL);<br />
digitalWrite(LED2, HIGH);<br />
delay(DEL);<br />
digitalWrite(LED3, HIGH);<br />
delay(DEL);<br />
digitalWrite(LED4, HIGH);<br />
delay(DEL);<br />
}</p>
<p></code></p>
<p><code>void myResetFunction() {<br />
delay(1000);<br />
digitalWrite(LED1, LOW);<br />
digitalWrite(LED2, LOW);<br />
digitalWrite(LED3, LOW);<br />
digitalWrite(LED4, LOW);<br />
}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://jeffkirsch.com/thoughtsandthings/2009/09/16/imagining-physical-computing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
