<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/wordpress-mu-1.2.3-2.2.1" -->
<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/"
	>

<channel>
	<title>careless whispers....</title>
	<link>http://itp.nyu.edu/blogs/cdc214</link>
	<description>(christian D cerrito goes to ITP, and he's never going to dance again....)</description>
	<pubDate>Wed, 02 Jul 2008 23:07:41 +0000</pubDate>
	<generator>http://wordpress.org/?v=wordpress-mu-1.2.3-2.2.1</generator>
	<language>en</language>
			<item>
		<title>Beacon Pendants: Code</title>
		<link>http://itp.nyu.edu/blogs/cdc214/2008/07/02/beacon-pendants-code/</link>
		<comments>http://itp.nyu.edu/blogs/cdc214/2008/07/02/beacon-pendants-code/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 23:07:41 +0000</pubDate>
		<dc:creator>Christian D Cerrito</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/blogs/cdc214/2008/07/02/beacon-pendants-code/</guid>
		<description><![CDATA[//Beacon Locator Thing V 1.0  A slamming together of Rob Faludi&#8217;s RSSI Reader, and Tom Igoes Analog Duplex Sender Code
//by Chris Cerrito
//FOR XBEE2
//******************************************************************************int
int RSSI = 0; // holds the Recieved Signal Strength Value, the value used to range find the Xbees
int address = 0; //holds the 16 bit address of the incoming signal
int lastSender = [...]]]></description>
			<content:encoded><![CDATA[<p>//Beacon Locator Thing V 1.0  A slamming together of Rob Faludi&#8217;s RSSI Reader, and Tom Igoes Analog Duplex Sender Code<br />
//by Chris Cerrito</p>
<p>//FOR XBEE2<br />
//******************************************************************************int<br />
int RSSI = 0; // holds the Recieved Signal Strength Value, the value used to range find the Xbees<br />
int address = 0; //holds the 16 bit address of the incoming signal<br />
int lastSender = 0; // last address we received an API packet from</p>
<p>//******************************************************************************#define</p>
<p>#define txLed 2 //indicates outgoing data<br />
#define rxLed 3 //indicates incoming data<br />
#define RedChannel 11 //red pwm pin<br />
#define GreenChannel 9 //green pwm pin<br />
#define BlueChannel 10 //blue pwm pin</p>
<p>int RedChanVal = 0;<br />
int GreenChanVal = 0;<br />
int BlueChanVal = 0;</p>
<p>unsigned long RedTimeOut = 0;<br />
unsigned long GreenTimeOut = 0;<br />
unsigned long StartTime = 0;</p>
<p>//*********************************************************************************</p>
<p>void setup() {<br />
Serial.begin(9600); //Lets talk.<br />
pinMode(txLed, OUTPUT);<br />
pinMode(rxLed, OUTPUT);<br />
pinMode(RedChannel, OUTPUT);<br />
pinMode(GreenChannel, OUTPUT);<br />
pinMode(BlueChannel, OUTPUT);<br />
setDestination();<br />
}</p>
<p>//***********************************************************************************WORKS?</p>
<p>void setDestination(){<br />
blink(2);               //blink to indicate that the destination code is about to run<br />
delay(1200);<br />
Serial.print(&#8221;+++&#8221;); //throw Xbee into command mode<br />
delay(500);<br />
char thisByte = 0;<br />
while (thisByte != &#8216;\r&#8217;) {           //Xbee will reply with an OK/r&#8230;wait for the ?r before printing<br />
if (Serial.available() &gt; 0) {      //if theres something in the serial, read it.<br />
thisByte = Serial.read();<br />
}<br />
}<br />
Serial.print(&#8221;ATDH0, DLFFFF\r&#8221;); //sets the address. Puts in the Xbee in Broadcast Mode&#8212;Anyone can listen<br />
delay(10);<br />
Serial.print(&#8221;ATMY0001\r&#8221;); //gives the Xbee an Address of 1. Use single digit addresses. CHANGE TO A DIFFERENT address fr each UNIT.<br />
delay(10);<br />
Serial.print(&#8221;ATID1124\r&#8221;); //set the PAN ID<br />
delay(10);<br />
Serial.print(&#8221;ATAP1\r&#8221;); //put the Xbee into API mode<br />
delay(10);<br />
Serial.print(&#8221;ATCN\r&#8221;); //take the Xbee out of command mode.<br />
delay(1200);<br />
blink(2);</p>
<p>}<br />
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++works</p>
<p>void blink(int howManyTimes) {<br />
for (int i=0; i&lt; howManyTimes; i++) {<br />
digitalWrite(txLed, HIGH);<br />
delay(200);<br />
digitalWrite(txLed, LOW);<br />
delay(1200);<br />
}<br />
}</p>
<p>//********************************************//Reads an API string</p>
<p>void APIread() {<br />
if (Serial.available() &gt; 13) {   //checks to make sure that we have received at least one frame worth of bytes<br />
int inByte = Serial.read();    //reads the incoming API string<br />
if (inByte == 0&#215;7E) {          // (first byte)looks for tilda (ox7E) place holder&#8230;marks the beginning of the string<br />
for (int i=0;i&lt;4;i++) {<br />
int junk = Serial.read();  // (next four bytes)  reads and discards the next four bytes that we&#8217;re not going to use<br />
}</p>
<p>address = Serial.read();       // the sixth byte is the low part of the address (ONLY USE ONE BYTE ADDRESSES!)<br />
RSSI = Serial.read();          // the seventh byte is the RSSI value</p>
<p>for (int i=0;i&lt;7;i++) {<br />
int junk = Serial.read();     //reads and discards the last six bytes of the API string. We dont need them. Whats in them? beats the crap outta me.<br />
}</p>
<p>AssignValues();                 //if there are values to assign from a successful serial read, assign them.<br />
}<br />
}</p>
<p>}</p>
<p>//*******************************************//</p>
<p>void AssignValues() {</p>
<p>if (address == 0003) {                              //if Xbee 3 is detected, give the red channel a value<br />
GreenChanVal=(100-RSSI)*2;<br />
GreenTimeOut=  millis();<br />
}</p>
<p>if (address == 0002) {                         //if Xbee2 is detected, give the green channel a value<br />
RedChanVal=(100-RSSI)*2;<br />
RedTimeOut = millis();<br />
}</p>
<p>if (address &gt; 0) {                         //if an address is recieved (Showing that the Xbee has<br />
digitalWrite(rxLed, HIGH);               //received and processed info.<br />
}<br />
else<br />
{digitalWrite(rxLed, LOW);<br />
}<br />
}<br />
//********************************************</p>
<p>void Lightup() {<br />
analogWrite(GreenChannel, GreenChanVal);<br />
analogWrite(RedChannel, RedChanVal);<br />
}</p>
<p>//**********************************************</p>
<p>void Timeout() {</p>
<p>if ((millis() - GreenTimeOut) &gt; 1000) {<br />
GreenChanVal=0;<br />
}</p>
<p>if ((millis() - RedTimeOut) &gt; 1000) {<br />
RedChanVal=0;<br />
}<br />
}</p>
<p>//*********************************************</p>
<p>void Sendjunk() {<br />
digitalWrite(txLed, HIGH);<br />
sendData(&#8221;X&#8221;,0xFFFF);    //SETS ADDRESS IS REDUNDANT<br />
delay(50);<br />
digitalWrite(txLed, LOW);<br />
}</p>
<p>//*******************************************</p>
<p>void loop () {<br />
StartTime = millis();<br />
APIread();<br />
Lightup();<br />
Sendjunk();<br />
Timeout();<br />
Serial.print(&#8221;GreenChanVal&#8221;);<br />
Serial.print(GreenChanVal);<br />
Serial.print(&#8221;RedChanVal&#8221;);<br />
Serial.print(RedChanVal);<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://itp.nyu.edu/blogs/cdc214/2008/07/02/beacon-pendants-code/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Beacon Pendants</title>
		<link>http://itp.nyu.edu/blogs/cdc214/2008/07/02/the-beacon-pendants/</link>
		<comments>http://itp.nyu.edu/blogs/cdc214/2008/07/02/the-beacon-pendants/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 22:59:27 +0000</pubDate>
		<dc:creator>Christian D Cerrito</dc:creator>
		
		<category><![CDATA[sociable objects]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/blogs/cdc214/2008/07/02/the-beacon-pendants/</guid>
		<description><![CDATA[
For my sociable objects final I decided to work on a project thats been the in back of my mind for quite some time. I&#8217;ve always wanted to make &#8220;social&#8221; jewelry; small wearable objects that have the ability to know if there are others of their kind in the area. For instance, say you were [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://itp.nyu.edu/blogs/cdc214/files/blt-schematic001.jpg" title="Beacon Pendants"><img src="http://itp.nyu.edu/blogs/cdc214/files/blt-schematic001.thumbnail.jpg" alt="Beacon Pendants" /></a></p>
<p>For my sociable objects final I decided to work on a project thats been the in back of my mind for quite some time. I&#8217;ve always wanted to make &#8220;social&#8221; jewelry; small wearable objects that have the ability to know if there are others of their kind in the area. For instance, say you were wearing, oh, i dunno, a pendant, and your friend had on a similar piece. Perhaps each pendant would glow, the closer the two of you are together, the brighter the response, the further apart, the dimmer. Say maybe there were three pendants, and each pendant had a specific color assigned to it; You were wearing the blue necklace, your friend the green, and your other friend the red. When the three of you were together, the pendants would flash brightly between all three colors, indicating social cohesion among the group. If one friend left early, the color show would be reduced to just two tones, and finally, when everyone parts ways, you would be left with a necklace dimly glowing it&#8217;s assigned color.</p>
<p>Another interesting idea: say the pendants were somewhat directional&#8230;Remember rabbit ears? Back in the day of braodcast TV (a world I&#8217;m afraid I still live in) you would have to adjust your antennae in order to pick up a station clearly. Say you were wearing one of these objects, and you suddenly noticed a flash of red, indicating that your friend was somewhere in the crowd. Using the pendant like a divining rod of sorts, you maneuver through the crowd, watching the light grow dimmer or stronger based the relative locations of both parties. Maybe you would be able to find one another?</p>
<p>And, finally, what if you were, say, at a huge party in the middle of the desert wearing a big furry coat, a space helmet, and stuck on sensory overload. A little help finding your way back to your camp would surely be a good thing. Perhaps there could be a beacon of sorts, broadcasting a much stronger signal then the pendants themselves, but in their range of hearing. Maybe, just maybe, you could navigate your way home using a somewhat directional antennae&#8230;.</p>
<p>So, in a nutshell, thats pretty much what I tried to accomplish. I haven&#8217;t gotten all the way there yet, but I do feel as though I&#8217;ve made significant progress. I&#8217;m using Xbees broadcasting API packets, and giving each unit the ability to parse those packets out, seeing who they&#8217;re from, and the signal strength of each unit in the system. Right now I have three breadboarded circuits, the &#8220;pendants&#8221; themselves, up and running. Theres a ton more to do, including shrinking these things down to a wearable size, but I think it&#8217;s all doable.</p>
<p>Below is a video of each circuit in action. Though they&#8217;re not mobile (i was so shocked that things actually worked that I didn&#8217;t want to ruin it by moving), each unit can see wach other, as indicated by the flashing tricolor RGB LEDS.</p>
<p>The diagram above is basically how I envision the system working.</p>
<p>Take a look below:</p>

			<br>
			<div id="videoPost_display_192">
				<script type="text/javascript">
				<!--
					document.write('<a href="http://www.vimeo.com/1271969" onClick="doQTObject(\'videoPost_display_192\',\'http://www.vimeo.com/1271969\',\'320\',\'240\',false); return false;">Click to Watch</a>');			
				// -->	
				</script>
				<noscript>
					<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" WIDTH="320" HEIGHT="240" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">
					<PARAM name="SRC" VALUE="http://www.vimeo.com/1271969" />
					<PARAM name="CONTROLLER" VALUE="true" />
					<PARAM name="AUTOPLAY" VALUE="false" />
					<PARAM name="SCALE" VALUE="ASPECT" />
					<EMBED SRC="http://www.vimeo.com/1271969" CONTROLLER="true" WIDTH="320" HEIGHT="240" AUTOPLAY="false" SCALE="ASPECT" PLUGINSPAGE="http://www.apple.com/quicktime/download/"></EMBED>
					</OBJECT>
				</noscript>
			</div>	
		]]></content:encoded>
			<wfw:commentRss>http://itp.nyu.edu/blogs/cdc214/2008/07/02/the-beacon-pendants/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Trash Talk</title>
		<link>http://itp.nyu.edu/blogs/cdc214/2008/07/02/trash-talk/</link>
		<comments>http://itp.nyu.edu/blogs/cdc214/2008/07/02/trash-talk/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 15:22:41 +0000</pubDate>
		<dc:creator>Christian D Cerrito</dc:creator>
		
		<category><![CDATA[Living Art]]></category>

		<category><![CDATA[Physical Computing]]></category>

		<category><![CDATA[Personal]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/blogs/cdc214/2008/07/02/trash-talk/</guid>
		<description><![CDATA[Trash Talk is in Conflux this year&#8230;.
MRS. DESI LIVES!!!!
I&#8217;ll be posting info about the rebuild as it happens. Should be pretty damn good.
]]></description>
			<content:encoded><![CDATA[<p>Trash Talk is in Conflux this year&#8230;.</p>
<p>MRS. DESI LIVES!!!!</p>
<p>I&#8217;ll be posting info about the rebuild as it happens. Should be pretty damn good.</p>
]]></content:encoded>
			<wfw:commentRss>http://itp.nyu.edu/blogs/cdc214/2008/07/02/trash-talk/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rock Paper Scissors</title>
		<link>http://itp.nyu.edu/blogs/cdc214/2008/06/30/rock-paper-scissors/</link>
		<comments>http://itp.nyu.edu/blogs/cdc214/2008/06/30/rock-paper-scissors/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 05:41:11 +0000</pubDate>
		<dc:creator>Christian D Cerrito</dc:creator>
		
		<category><![CDATA[sociable objects]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/blogs/cdc214/2008/06/30/rock-paper-scissors/</guid>
		<description><![CDATA[Rock Paper Scissors
Or
What a Pain in the Ass.
So, building and coding a wireless rock-paper-scissors game proved to be way, way harder then I would have ever expected. Dave Spector and I started off using a slightly different approach then most everyone else seemed to take, using the Duplex Sender code as a foundation. Our idea [...]]]></description>
			<content:encoded><![CDATA[<p>Rock Paper Scissors<br />
Or<br />
What a Pain in the Ass.</p>
<p>So, building and coding a wireless rock-paper-scissors game proved to be way, way harder then I would have ever expected. Dave Spector and I started off using a slightly different approach then most everyone else seemed to take, using the Duplex Sender code as a foundation. Our idea seemed incredibly simple:</p>
<p>1) Use a 10k pot to select rock, paper, or scissors<br />
2) Send the pot value via the Analog Duplex Sender code.<br />
3) Insert that value into a RPS game.</p>
<p>And of course in the end, nothing worked.</p>
<p>After  struggling, changing our code, swearing, and a lot of Robs help, we managed to get something together that allowed use to play 1 or 2 games of RPS, and then crashed completely. I still have no idea why this happened, and would like to take another look at all the code when I have a bit more time.</p>
<p>I still really don’t understand why our original approach failed so miserably.</p>
<p>Pics:</p>
<p>Code:</p>
<p>/*<br />
XBee Analog Duplex sender<br />
Language: Wiring/Arduino</p>
<p>This sketch configures an XBee radio via the serial port,<br />
sends the value of an analog sensor out, and listens for<br />
input from the radio, using it to set the value of<br />
a PWM output.</p>
<p>Thanks to Robert Faludi for the critique and improvements<br />
*/<br />
#define sensorPin 0         // input sensor<br />
#define txLed 2             // LED to indicate outgoing data<br />
#define rxLed 3             // LED to indicate incoming data<br />
#define analogLed 9         // LED that will change brightness with incoming value<br />
#define threshold 10        // how much change you need to see on<br />
// the sensor before sending</p>
<p>int gameState = 1; // 1 = choice, 2 = tx/rx, 3 = winner mode<br />
int brightness = 0;<br />
int sensorValue = 0;<br />
int x = 0;<br />
int y = 0;</p>
<p>int ledScissors = 7;<br />
int ledRock = 5;<br />
int ledPaper = 6;<br />
int ledWinner = 4;<br />
int ledLoser = 8;<br />
int attackSwitchPin = 12;    // Analog input pin that the switch is attached to<br />
int attackSwitchValue = 0; //value read from attackSwitch</p>
<p>int lastSensorReading = 0;  // previous state of the switch</p>
<p>int inByte= -1;             // incoming byte from serial RX<br />
char inString[6];           // string for incoming serial data<br />
int stringPos = 0;          // string index counter</p>
<p>void setup() {<br />
// configure serial communications:<br />
Serial.begin(9600);</p>
<p>// configure output pins:<br />
pinMode(txLed, OUTPUT);<br />
pinMode(rxLed, OUTPUT);<br />
pinMode (analogLed, OUTPUT);</p>
<p>pinMode(ledRock, OUTPUT);<br />
pinMode(ledScissors, OUTPUT);<br />
pinMode(ledPaper, OUTPUT);<br />
pinMode(ledWinner, OUTPUT);<br />
pinMode(ledLoser, OUTPUT);</p>
<p>digitalWrite(ledRock, LOW);  //turn off led<br />
digitalWrite(ledPaper, LOW);  //turn off led<br />
digitalWrite(ledScissors, LOW);   //turn off led<br />
digitalWrite(ledWinner, LOW);   //turn off led<br />
digitalWrite(ledLoser, LOW);   //turn off led</p>
<p>// set XBee&#8217;s destination address:<br />
setDestination();<br />
// blink the TX LED indicating that the main program&#8217;s about to start:<br />
blink(3);<br />
}<br />
void setDestination() {<br />
// put the radio in command mode:<br />
Serial.print(&#8221;+++&#8221;);<br />
// wait for the radio to respond with &#8220;OK\r&#8221;<br />
char thisByte = 0;<br />
while (thisByte != &#8216;\r&#8217;) {<br />
if (Serial.available() &gt; 0) {<br />
thisByte = Serial.read();<br />
}<br />
}</p>
<p>// set the destination address, using 16-bit addressing.<br />
// if you&#8217;re using two radios, one radio&#8217;s destination<br />
// should be the other radio&#8217;s MY address, and vice versa:<br />
Serial.print(&#8221;ATDH0, DL5678\r&#8221;);  //sofia switch this to 1234<br />
// set my address using 16-bit addressing:<br />
Serial.print(&#8221;ATMY1234\r&#8221;);    ///sofia switch to 5678<br />
// set the PAN ID. If you&#8217;re working in a place where many people<br />
// are using XBees, you should set your own PAN ID distinct<br />
// from other projects.<br />
Serial.print(&#8221;ATID1124\r&#8221;);<br />
// put the radio in data mode:<br />
Serial.print(&#8221;ATCN\r&#8221;);<br />
}<br />
// Blink the tx LED:<br />
void blink(int howManyTimes) {<br />
for (int i=0; i&lt; howManyTimes; i++) {<br />
digitalWrite(txLed, HIGH);<br />
delay(200);<br />
digitalWrite(txLed, LOW);<br />
delay(200);<br />
}<br />
}</p>
<p>void loop() {</p>
<p>while (gameState == 1) {<br />
getInput();<br />
if (digitalRead(attackSwitchPin) == HIGH) {<br />
gameState = 2;<br />
}<br />
}</p>
<p>while (gameState == 2) {<br />
// send my choice and listen for opponent&#8217;s choice</p>
<p>// listen for incoming serial data:<br />
if (Serial.available() &gt; 0) {<br />
// turn on the RX LED whenever you&#8217;re reading data:<br />
digitalWrite(rxLed, HIGH);<br />
handleSerial();<br />
}<br />
else {<br />
// turn off the receive LED when there&#8217;s no incoming data:<br />
digitalWrite(rxLed, LOW);<br />
}</p>
<p>// if there&#8217;s something to send, send it:<br />
if (sensorValue &gt;= 0) {</p>
<p>//light the tx LED to say you&#8217;re sending:<br />
digitalWrite(txLed, HIGH);</p>
<p>Serial.print(sensorValue, DEC );<br />
Serial.print(&#8221;\r&#8221;);<br />
delay(50);<br />
// turn off the tx LED:<br />
digitalWrite(txLed, LOW);<br />
}</p>
<p>if (brightness &lt; 5 &amp;&amp; brightness&gt;0){<br />
y = 1;<br />
}</p>
<p>if (brightness &gt;= 5 &amp;&amp; brightness&lt;= 250){<br />
y = 2;<br />
}</p>
<p>if (brightness &gt; 250){<br />
y=3;<br />
}</p>
<p>if (y &gt; 0) {<br />
Serial.print(sensorValue, DEC );<br />
delay(50);<br />
Serial.print(&#8221;\r&#8221;);<br />
delay(50);</p>
<p>gameState = 3;<br />
}</p>
<p>while (gameState == 3) {<br />
// calculate who won and show the output on happy LEDs</p>
<p>if (x == 1 ){<br />
digitalWrite(ledRock, HIGH); //turn on led<br />
}</p>
<p>if (x == 2 ){<br />
digitalWrite(ledPaper, HIGH);  //turn on led<br />
}</p>
<p>if (x == 3 ){<br />
digitalWrite(ledScissors, HIGH);   //turn on led<br />
}</p>
<p>if (y == 1 ){<br />
digitalWrite(ledRock, HIGH); //turn on led<br />
//Serial.println (&#8221;Player 2 Chose ROCK!&#8221;);<br />
}</p>
<p>if (y == 2 ){<br />
// Serial.println (&#8221;Player 2 Chose PAPER!&#8221;);<br />
digitalWrite(ledPaper, HIGH);  //turn on led<br />
}</p>
<p>if (y == 3 ){<br />
// Serial.println (&#8221;Player 2 Chose SCISSORS!&#8221;);<br />
digitalWrite(ledScissors, HIGH);   //turn on led<br />
}</p>
<p>if (x == y) {<br />
//Serial.println(&#8221;It&#8217;s a draw!&#8221;);<br />
digitalWrite(ledWinner, HIGH);   //turn on led<br />
digitalWrite(ledLoser, HIGH);   //turn on led<br />
}<br />
if (x == 1 &amp;&amp; y == 2) {<br />
//Serial.println(&#8221;Paper covers Rock!  PLAYER 2 WINS!&#8221;);<br />
digitalWrite(ledLoser, HIGH);   //turn off led<br />
}<br />
if (y == 1 &amp;&amp; x == 2) {<br />
//Serial.println(&#8221;Paper covers Rock!  PLAYER 1 WINS!&#8221;);<br />
digitalWrite(ledWinner, HIGH);   //turn on led<br />
}</p>
<p>if (x == 1 &amp;&amp; y == 3) {<br />
//Serial.println(&#8221;Rock smashes Scissors!  PLAYER 1 WINS!&#8221;);<br />
digitalWrite(ledWinner, HIGH);   //turn on led<br />
}<br />
if (y == 1 &amp;&amp; x == 3) {<br />
//Serial.println(&#8221;Rock smashes Scissors!  PLAYER 2 WINS!&#8221;);<br />
digitalWrite(ledLoser, HIGH);   //turn off led<br />
}<br />
if (x == 2 &amp;&amp; y == 3) {<br />
//Serial.println(&#8221;Scissors cuts Paper!  PLAYER 2 WINS!&#8221;);<br />
digitalWrite(ledLoser, HIGH);   //turn off led<br />
}<br />
if (y == 2 &amp;&amp; x == 3) {<br />
//Serial.println(&#8221;Scissors cuts Paper!  PLAYER 1 WINS!&#8221;);<br />
digitalWrite(ledWinner, HIGH);   //turn on led<br />
}</p>
<p>if (digitalRead(attackSwitchPin) == HIGH) {<br />
digitalWrite(ledRock, LOW);  //turn off led<br />
digitalWrite(ledPaper, LOW);  //turn off led<br />
digitalWrite(ledScissors, LOW);   //turn off led<br />
digitalWrite(ledWinner, LOW);   //turn off led<br />
digitalWrite(ledLoser, LOW);   //turn off led<br />
delay(3000);<br />
y = 0;<br />
brightness = 0;<br />
Serial.flush();<br />
gameState = 1;</p>
<p>}<br />
//    delay (3000);<br />
//    y = 0;</p>
<p>}</p>
<p>}<br />
}</p>
<p>void getInput() {<br />
// listen to the potentiometer:<br />
sensorValue = analogRead(sensorPin)/4;</p>
<p>if (sensorValue &gt; 0) { // if we got a real value from the readSensor() function<br />
if (sensorValue &lt; 5) {<br />
digitalWrite(ledRock, HIGH);<br />
digitalWrite(ledPaper, LOW);<br />
digitalWrite(ledScissors, LOW);<br />
x = 1;<br />
}</p>
<p>if (sensorValue &gt; 4 &amp;&amp; sensorValue &lt;  251) {<br />
digitalWrite(ledRock, LOW);<br />
digitalWrite(ledPaper, HIGH);<br />
digitalWrite(ledScissors, LOW);<br />
x = 2;<br />
}<br />
if (sensorValue &gt; 250) {<br />
digitalWrite(ledRock, LOW);<br />
digitalWrite(ledPaper, LOW);<br />
digitalWrite(ledScissors, HIGH);<br />
x = 3;<br />
}<br />
}<br />
}</p>
<p>void handleSerial() {<br />
inByte = Serial.read();<br />
// save only ASCII numeric characters (ASCII 0 - 9):<br />
if ((inByte &gt;= &#8216;0&#8242;) &amp;&amp; (inByte &lt;= &#8216;9&#8242;)){<br />
inString[stringPos] = inByte;<br />
stringPos++;<br />
}<br />
// if you get an ASCII carriage return:</p>
<p>if (inByte == &#8216;\r&#8217;) {<br />
// convert the string to a number:<br />
brightness = atoi(inString);<br />
// set the analog output LED:<br />
//analogWrite(analogLed, brightness);</p>
<p>// put zeroes in the array<br />
for (int c = 0; c &lt; stringPos; c++) {<br />
inString[c] = 0;<br />
}<br />
// reset the string pointer:<br />
stringPos = 0;<br />
}<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://itp.nyu.edu/blogs/cdc214/2008/06/30/rock-paper-scissors/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Analog Duplex Sender</title>
		<link>http://itp.nyu.edu/blogs/cdc214/2008/06/30/analog-duplex-sender/</link>
		<comments>http://itp.nyu.edu/blogs/cdc214/2008/06/30/analog-duplex-sender/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 05:06:34 +0000</pubDate>
		<dc:creator>Christian D Cerrito</dc:creator>
		
		<category><![CDATA[sociable objects]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/blogs/cdc214/2008/06/30/analog-duplex-sender/</guid>
		<description><![CDATA[Analog Duplex Sender Lab
(Take a look at it all in action at: http://silverapple.blip.tv/#1006798)
This lab was fairly straightforward, yet still took quite a bit of time. I had an issue setting up my Xbees, but realized it all stemmed from the fact that they had been used before and needed to be reset.
Another issue was a [...]]]></description>
			<content:encoded><![CDATA[<p>Analog Duplex Sender Lab</p>
<p>(Take a look at it all in action at: http://silverapple.blip.tv/#1006798)</p>
<p>This lab was fairly straightforward, yet still took quite a bit of time. I had an issue setting up my Xbees, but realized it all stemmed from the fact that they had been used before and needed to be reset.</p>
<p>Another issue was a loose pin on the breakout board, due to the fact that I did a pretty rushed soldering job.</p>
<p>All in All, after a bunch of obnoxious p-comp issues, eddie and were up and running.</p>
<p>Basically, what was going is that we were wirelessly using two potentiometers to control the brightness of two LEDS. Values were being read by the Arduinos, with the Xbees sending values back and forth.</p>
<p>The code is straight out of Making Things Talk by Tom Igoe. If you want to know more about it, pick a copy up, it’s well worth it.</p>
<p>/*<br />
XBee Analog Duplex sender<br />
Language: Wiring/Arduino</p>
<p>This sketch configures an XBee radio via the serial port,<br />
sends the value of an analog sensor out, and listens for input<br />
from the radio, using it to set the value of a PWM output.<br />
Thanks to Robert Faludi for the critique and improvements.<br />
*/</p>
<p>#define sensorPin 0         // input sensor<br />
#define txLed 2             // LED to indicate outgoing data<br />
#define rxLed 3             // LED to indicate incoming data<br />
#define analogLed 9         // LED that changes brightness with incoming value<br />
#define threshold 10        // how much change you need to see on<br />
// the sensor before sending</p>
<p>int lastSensorReading = 0;  // previous state of the switch</p>
<p>int inByte= -1;             // incoming byte from serial RX<br />
char inString[6];           // string for incoming serial data<br />
int stringPos = 0;          // string index counter</p>
<p>void setup() {<br />
// configure serial communications:<br />
Serial.begin(9600);</p>
<p>// configure output pins:<br />
pinMode(txLed, OUTPUT);<br />
pinMode(rxLed, OUTPUT);<br />
pinMode (analogLed, OUTPUT);</p>
<p>// set XBee&#8217;s destination address:<br />
setDestination();<br />
// blink the TX LED indicating that the main program&#8217;s about to start:<br />
blink(3);<br />
}<br />
void setDestination() {<br />
// put the radio in command mode:<br />
Serial.print(&#8221;+++&#8221;);<br />
// wait for the radio to respond with &#8220;OK\r&#8221;<br />
char thisByte = 0;<br />
while (thisByte != &#8216;\r&#8217;) {<br />
if (Serial.available() &gt; 0) {<br />
thisByte = Serial.read();<br />
}<br />
}</p>
<p>// set the destination address, using 16-bit addressing.<br />
// if you&#8217;re using two radios, one radio&#8217;s destination<br />
// should be the other radio&#8217;s MY address, and vice versa:<br />
Serial.print(&#8221;ATDH0, DL5678\r&#8221;);<br />
// set my address using 16-bit addressing:<br />
Serial.print(&#8221;ATMY1234\r&#8221;);<br />
// set the PAN ID. If you&#8217;re working in a place where many people<br />
// are using XBees, you should set your own PAN ID distinct<br />
// from other projects.<br />
Serial.print(&#8221;ATID1124\r&#8221;);<br />
// put the radio in data mode:<br />
Serial.print(&#8221;ATCN\r&#8221;);<br />
}<br />
// Blink the tx LED:<br />
void blink(int howManyTimes) {<br />
for (int i=0; i&lt; howManyTimes; i++) {<br />
digitalWrite(txLed, HIGH);<br />
delay(200);<br />
digitalWrite(txLed, LOW);<br />
delay(200);<br />
}<br />
}</p>
<p>void loop() {<br />
// listen for incoming serial data:<br />
if (Serial.available() &gt; 0) {<br />
// turn on the RX LED whenever you&#8217;re reading data:<br />
digitalWrite(rxLed, HIGH);<br />
handleSerial();<br />
}<br />
else {<br />
// turn off the receive LED when there&#8217;s no incoming data:<br />
digitalWrite(rxLed, LOW);<br />
}</p>
<p>// listen to the potentiometer:<br />
char sensorValue = readSensor();</p>
<p>// if there&#8217;s something to send, send it:<br />
if (sensorValue &gt; 0) {<br />
//light the tx LED to say you&#8217;re sending:<br />
digitalWrite(txLed, HIGH);</p>
<p>Serial.print(sensorValue, DEC );<br />
Serial.print(&#8221;\r&#8221;);</p>
<p>// turn off the tx LED:<br />
digitalWrite(txLed, LOW);<br />
}<br />
}<br />
void handleSerial() {<br />
inByte = Serial.read();<br />
// save only ASCII numeric characters (ASCII 0 - 9):<br />
if ((inByte &gt;= &#8216;0&#8242;) &amp;&amp; (inByte &lt;= &#8216;9&#8242;)){<br />
inString[stringPos] = inByte;<br />
stringPos++;<br />
}<br />
// if you get an ASCII carriage return:</p>
<p>if (inByte == &#8216;\r&#8217;) {<br />
// convert the string to a number:<br />
int brightness = atoi(inString);<br />
// set the analog output LED:<br />
analogWrite(analogLed, brightness);</p>
<p>// put zeroes in the array<br />
for (int c = 0; c &lt; stringPos; c++) {<br />
inString[c] = 0;<br />
}<br />
// reset the string pointer:<br />
stringPos = 0;<br />
}<br />
}</p>
<p>char readSensor() {<br />
char message = 0;<br />
// read the sensor:<br />
int sensorReading = analogRead(sensorPin);</p>
<p>// look for a change from the last reading<br />
// that&#8217;s greater than the threshold:<br />
if (abs(sensorReading - lastSensorReading) &gt; threshold) {<br />
message = sensorReading/4;<br />
lastSensorReading = sensorReading;<br />
}<br />
return message;<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://itp.nyu.edu/blogs/cdc214/2008/06/30/analog-duplex-sender/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Nod-Off Hat</title>
		<link>http://itp.nyu.edu/blogs/cdc214/2008/06/30/the-nod-off-hat/</link>
		<comments>http://itp.nyu.edu/blogs/cdc214/2008/06/30/the-nod-off-hat/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 04:21:49 +0000</pubDate>
		<dc:creator>Christian D Cerrito</dc:creator>
		
		<category><![CDATA[sociable objects]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/blogs/cdc214/2008/06/30/the-nod-off-hat/</guid>
		<description><![CDATA[Ah…retroactive blogging.
Our first assignment for sociable objects was to address a problem on the ITP floor. I decided to tackle one near and dear to my heart: The problem of nodding off while trying to get work done. On more then one occasion over the past year, I’ve woken up with keyboard tread marks on [...]]]></description>
			<content:encoded><![CDATA[<p>Ah…retroactive blogging.</p>
<p>Our first assignment for sociable objects was to address a problem on the ITP floor. I decided to tackle one near and dear to my heart: The problem of nodding off while trying to get work done. On more then one occasion over the past year, I’ve woken up with keyboard tread marks on my cheek and IC’s in my hair.</p>
<p>I once even tried to use an Arduino for a pillow…Turns out that drool and micro controllers don’t mix.</p>
<p>Anyway, in order to make a nod-off alarm, I decided to attach an accelerometer to my hat. The accelerometer would act as a sophisticated tilt sensor…If my head tilts too far forward, or too far to the side, an annoying piezo buzzer sounds, waking me up.</p>
<p>This all worked out pretty well. I can’t help but think of this also as some sort of Posture-o-meter or something. Maybe I’ll trying messing around with the Y-axis value in the future.</p>
<p>This project was pretty simple and straightforward, but also represents the frist time that I’ve written code in MONTHS. It took me a little while to get back in the swing of things, but it felt good to be coding (the main reason I’m taking this class).</p>
<p>Anyway, here’s the code, again, simple for most:</p>
<p>(photos of the board coming soon)</p>
<p>int analog0 = 0; // select the input pin for the potentiometer<br />
int XaxisVal0 = 0; // variable to store the value coming from the sensor<br />
int squirtPin = 13; // on/off for the squirtgun</p>
<p>void setup() {<br />
Serial.begin(9600); // use the serial port to send the values back to the computer<br />
pinMode(squirtPin, OUTPUT); //declare squirtPin an output<br />
}</p>
<p>void loop() {<br />
XaxisVal0 = analogRead(analog0); // read the value from the sensor<br />
if(XaxisVal0 &gt; 150 || XaxisVal0 &lt; 87){digitalWrite(squirtPin, HIGH);<br />
}<br />
else<br />
{digitalWrite(squirtPin, LOW);<br />
}</p>
<p>Serial.println(&#8221;XaxisVal0&#8243;); // print the value to the serial port<br />
Serial.println(XaxisVal0); // print the value to the serial port<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://itp.nyu.edu/blogs/cdc214/2008/06/30/the-nod-off-hat/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The BLT</title>
		<link>http://itp.nyu.edu/blogs/cdc214/2008/06/16/the-blt/</link>
		<comments>http://itp.nyu.edu/blogs/cdc214/2008/06/16/the-blt/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 17:33:19 +0000</pubDate>
		<dc:creator>Christian D Cerrito</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/blogs/cdc214/2008/06/16/the-blt/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><a href="http://itp.nyu.edu/blogs/cdc214/files/blt-schematic001.jpg" title="blt-schematic001.jpg"><img src="http://itp.nyu.edu/blogs/cdc214/files/blt-schematic001.thumbnail.jpg" alt="blt-schematic001.jpg" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://itp.nyu.edu/blogs/cdc214/2008/06/16/the-blt/feed/</wfw:commentRss>
		</item>
		<item>
		<title></title>
		<link>http://itp.nyu.edu/blogs/cdc214/2008/06/16/184/</link>
		<comments>http://itp.nyu.edu/blogs/cdc214/2008/06/16/184/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 17:30:47 +0000</pubDate>
		<dc:creator>Christian D Cerrito</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/blogs/cdc214/2008/06/16/184/</guid>
		<description><![CDATA[file:///Users/christiancerrito/Desktop/BLT%20schematic.001.jpg
]]></description>
			<content:encoded><![CDATA[<p>file:///Users/christiancerrito/Desktop/BLT%20schematic.001.jpg</p>
]]></content:encoded>
			<wfw:commentRss>http://itp.nyu.edu/blogs/cdc214/2008/06/16/184/feed/</wfw:commentRss>
		</item>
		<item>
		<title>STEPPERS!</title>
		<link>http://itp.nyu.edu/blogs/cdc214/2008/05/01/steppers/</link>
		<comments>http://itp.nyu.edu/blogs/cdc214/2008/05/01/steppers/#comments</comments>
		<pubDate>Thu, 01 May 2008 20:11:04 +0000</pubDate>
		<dc:creator>Christian D Cerrito</dc:creator>
		
		<category><![CDATA[Toy Design]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/blogs/cdc214/2008/05/01/steppers/</guid>
		<description><![CDATA[take a gander: http://beatsteppers.com  
]]></description>
			<content:encoded><![CDATA[<p>take a gander: http://beatsteppers.com  </p>
]]></content:encoded>
			<wfw:commentRss>http://itp.nyu.edu/blogs/cdc214/2008/05/01/steppers/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Draw Synth</title>
		<link>http://itp.nyu.edu/blogs/cdc214/2008/03/26/the-draw-synth/</link>
		<comments>http://itp.nyu.edu/blogs/cdc214/2008/03/26/the-draw-synth/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 04:41:39 +0000</pubDate>
		<dc:creator>Christian D Cerrito</dc:creator>
		
		<category><![CDATA[Living Art]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/blogs/cdc214/2008/03/26/the-draw-synth/</guid>
		<description><![CDATA[I&#8217;m trying to make a simple electronic instrument that uses drawing as an input. Graphite, when spread on paper, can conduct electricity, and produces electrical resistence. If I can read that resistence, and input it to an oscillator, I should be able to make something relatively funky and straightforward. Once again, I have avoided using an [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m trying to make a simple electronic instrument that uses drawing as an input. Graphite, when spread on paper, can conduct electricity, and produces electrical resistence. If I can read that resistence, and input it to an oscillator, I should be able to make something relatively funky and straightforward. Once again, I have avoided using an arduino this semester. Shame on me&#8230;.It&#8217;s interesting though, I haven&#8217;t needed one yet. I&#8217;m going to be the rustiest programmer in the world. More to follow on this. </p>
]]></content:encoded>
			<wfw:commentRss>http://itp.nyu.edu/blogs/cdc214/2008/03/26/the-draw-synth/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
