<?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>For our dear Husbands</title>
	<link>http://itp.nyu.edu/blogs/sid213_cem</link>
	<description>FINAL PROJECT PHYSICAL COMPUTING</description>
	<pubDate>Sat, 22 Dec 2007 15:01:11 +0000</pubDate>
	<generator>http://wordpress.org/?v=wordpress-mu-1.2.3-2.2.1</generator>
	<language>en</language>
			<item>
		<title>video for our prototype</title>
		<link>http://itp.nyu.edu/blogs/sid213_cem/2007/12/22/video-for-our-prototype/</link>
		<comments>http://itp.nyu.edu/blogs/sid213_cem/2007/12/22/video-for-our-prototype/#comments</comments>
		<pubDate>Sat, 22 Dec 2007 15:01:11 +0000</pubDate>
		<dc:creator>ml1949</dc:creator>
		
		<category><![CDATA[documentation]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/blogs/sid213_cem/2007/12/22/video-for-our-prototype/</guid>
		<description><![CDATA[click to watch
]]></description>
			<content:encoded><![CDATA[<p id="top" /><strong><a href="http://picasaweb.google.com/sandraxi/SHOW/photo#5145803934079091234">click to watch</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://itp.nyu.edu/blogs/sid213_cem/2007/12/22/video-for-our-prototype/feed/</wfw:commentRss>
		</item>
		<item>
		<title>final working code :D</title>
		<link>http://itp.nyu.edu/blogs/sid213_cem/2007/12/12/final-working-code-d/</link>
		<comments>http://itp.nyu.edu/blogs/sid213_cem/2007/12/12/final-working-code-d/#comments</comments>
		<pubDate>Wed, 12 Dec 2007 08:00:20 +0000</pubDate>
		<dc:creator>ml1949</dc:creator>
		
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/blogs/sid213_cem/2007/12/12/final-working-code-d/</guid>
		<description><![CDATA[
// Variables for calculating PERIOD and SEX pointers
//float speedPointer();
int encoder[108];
//PROGMEM prog_uchar encoder[106];
//prog_uchar encoder[106] PROGMEM;
//unsigned char lastEncoder0Pos;
int displayRead;
int lastEncoder0Pos;
unsigned char encoder0Pos;
int steps;
int timePeriod=60;
int passedDays=15;
int cycleCount;
int gear20=18;
int gear24=96;
int delayRate;
int pointerPos=0;
//int sexPoint=0;
//int reading[107];
int initialSteps;
int delayMillis;
int savedMillis;
int ellapsedMillis;
int displayEncoder;
//int lastEncoder0Pos;
int lastChange;
//Variables for communicating to Processing
int firstByte; // value for Period
int secondByte; // value for Initial Date
int serialInArray[3]; // array [...]]]></description>
			<content:encoded><![CDATA[<p id="top" /><code><br />
// Variables for calculating PERIOD and SEX pointers<br />
//float speedPointer();</p>
<p>int encoder[108];<br />
//PROGMEM prog_uchar encoder[106];<br />
//prog_uchar encoder[106] PROGMEM;<br />
//unsigned char lastEncoder0Pos;<br />
int displayRead;<br />
int lastEncoder0Pos;<br />
unsigned char encoder0Pos;<br />
int steps;</code></p>
<p>int timePeriod=60;<br />
int passedDays=15;<br />
int cycleCount;<br />
int gear20=18;<br />
int gear24=96;<br />
int delayRate;<br />
int pointerPos=0;<br />
//int sexPoint=0;<br />
//int reading[107];<br />
int initialSteps;<br />
int delayMillis;<br />
int savedMillis;<br />
int ellapsedMillis;<br />
int displayEncoder;<br />
//int lastEncoder0Pos;<br />
int lastChange;</p>
<p>//Variables for communicating to Processing<br />
int firstByte; // value for Period<br />
int secondByte; // value for Initial Date<br />
int serialInArray[3]; // array for storing 3 bytes as they arrive from processing<br />
int serialCount = 0; // for counting the number of bytes received</p>
<p>// ENCODER Variables<br />
#define encoder0PinA  2<br />
#define encoder0PinB  3<br />
//volatile int encoder0Pos = 0;</p>
<p>// Stepper Motor Variables<br />
int counter=0;<br />
#include &lt;Stepper.h&gt;<br />
//Motor Steps for Motor 1<br />
#define motor1Steps 24     // change this depending on the number of steps<br />
// Steps fo motor 2<br />
#define motor2Steps 20                         // per revolution of your motor<br />
// Pins 4 to 7 for Motor 1<br />
#define motorPin1 8<br />
#define motorPin2 9<br />
#define motorPin3 10<br />
#define motorPin4 11<br />
//Pins 8-11 for Motor 2<br />
#define motorPin5 4<br />
#define motorPin6 5<br />
#define motorPin7 6<br />
#define motorPin8 7<br />
// initialize of the Stepper library:<br />
Stepper myStepper(motor1Steps, motorPin1,motorPin2,motorPin3,motorPin4);<br />
Stepper myStepper2(motor2Steps,motorPin5,motorPin6,motorPin7,motorPin8);</p>
<p>void setup() {<br />
// set the motor speed at 60 RPMS:<br />
myStepper.setSpeed(10);<br />
myStepper2.setSpeed(60);</p>
<p>// Initialize the Serial port:<br />
Serial.begin(9600);<br />
//  myStepper.step(10);</p>
<p>//SETUP FOR ENCODER<br />
pinMode(encoder0PinA, INPUT);<br />
digitalWrite(encoder0PinA, HIGH);       // turn on pullup resistor<br />
pinMode(encoder0PinB, INPUT);<br />
digitalWrite(encoder0PinB, HIGH);       // turn on pullup resistor<br />
attachInterrupt(0, doEncoder, CHANGE);  // encoder pin on interrupt 0 - pin 2<br />
Serial.begin (9600);<br />
Serial.println(&#8221;start&#8221;);                // a personal quirk<br />
savedMillis=millis();<br />
initialSteps=-106.67*passedDays/timePeriod;<br />
delayMillis=9.375*timePeriod;<br />
myStepper2.step(int(initialSteps));<br />
Serial.println(initialSteps);<br />
}</p>
<p>void loop() {</p>
<p>/*<br />
if (Serial.available() &gt; 0) {<br />
// read the most recent byte (which will be from 0 to 255)<br />
if(Serial.read()==65){<br />
timePeriod = Serial.read();<br />
passedDays = Serial.read();<br />
}<br />
}<br />
*/<br />
/*<br />
serialInArray[serialCount] = Serial.read(); // read a byte sent by processing<br />
serialCount++;  // increment number of bytes received<br />
if (serialCount &gt; 2 ) {  // when 3 bytes received<br />
firstByte = serialInArray[1]; // get value for PERIOD<br />
secondByte = serialInArray[2]; // get value for INITIAL DATE<br />
serialCount = 0;<br />
}<br />
*/</p>
<p>// delayMillis=0;<br />
// Serial.println(delayMillis);</p>
<p>ellapsedMillis=millis()-savedMillis;<br />
//  Serial.println(ellapsedMillis);<br />
if(ellapsedMillis&gt;=delayMillis){<br />
// save the reading<br />
encoder[pointerPos]=encoder0Pos;<br />
Serial.println(&#8221;writingwhenmillis-lastChange&gt;=delayMillis&#8221;);<br />
Serial.println(pointerPos);<br />
Serial.println(encoder0Pos, DEC);<br />
//Serial.println(ellapsedMillis);<br />
myStepper2.step(-1);<br />
savedMillis=millis();<br />
pointerPos+=1;<br />
//  lastChange = millis();<br />
// if (encoder[pointerPos]&gt;0)  {<br />
if(cycleCount&gt;0){<br />
Serial.println(&#8221;encoder[pointerPos]&#8221;);<br />
Serial.println(encoder[pointerPos],DEC);<br />
Serial.println(encoder0Pos, DEC);</p>
<p>steps=int(0.375*encoder[pointerPos]-0.375*encoder0Pos);<br />
Serial.println(steps);<br />
myStepper.step(steps);<br />
}<br />
/*<br />
//  if (millis() - lastChange &gt;= delayMillis*0.8) {<br />
if (millis() - savedMillis &gt;= delayMillis*0.8) {<br />
// save the reading<br />
encoder[pointerPos]=encoder0Pos;<br />
Serial.println(&#8221;writingwhenmillis-lastChange&gt;=delayMillis&#8221;);<br />
Serial.println(pointerPos);<br />
Serial.println(encoder0Pos, DEC);<br />
//prog_uchar encoder[pointerPos]=lastEncoder0Pos;<br />
}<br />
}<br />
*/<br />
if (pointerPos == 106){<br />
cycleCount+=1;<br />
pointerPos=0;<br />
if (cycleCount==3){<br />
myStepper2.step(3);<br />
}<br />
Serial.println(&#8221;cycleCount&#8221;);<br />
}<br />
}</p>
<p>}</p>
<p>void doEncoder(){<br />
if (digitalRead(encoder0PinA) == HIGH) {   // found a low-to-high on channel A<br />
if (digitalRead(encoder0PinB) == LOW) {  // check channel B to see which way<br />
// encoder is turning<br />
encoder0Pos = encoder0Pos - 1;         // CCW<br />
}<br />
else {<br />
encoder0Pos = encoder0Pos + 1;         // CW<br />
}<br />
}<br />
else                                        // found a high-to-low on channel A<br />
{<br />
if (digitalRead(encoder0PinB) == LOW) {   // check channel B to see which way<br />
// encoder is turning<br />
encoder0Pos = encoder0Pos + 1;          // CW<br />
}<br />
else {<br />
encoder0Pos = encoder0Pos - 1;          // CCW<br />
}<br />
}</p>
<p>if(encoder0Pos&gt;64){<br />
encoder0Pos=1;<br />
}<br />
if(encoder0Pos&lt;1){<br />
encoder0Pos=64;<br />
}<br />
// Serial.println (encoder0Pos, DEC);          // debug - remember to comment out<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://itp.nyu.edu/blogs/sid213_cem/2007/12/12/final-working-code-d/feed/</wfw:commentRss>
		</item>
		<item>
		<title>documentation photos</title>
		<link>http://itp.nyu.edu/blogs/sid213_cem/2007/12/10/documentation-photos/</link>
		<comments>http://itp.nyu.edu/blogs/sid213_cem/2007/12/10/documentation-photos/#comments</comments>
		<pubDate>Mon, 10 Dec 2007 22:55:50 +0000</pubDate>
		<dc:creator>ml1949</dc:creator>
		
		<category><![CDATA[documentation]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/blogs/sid213_cem/2007/12/10/documentation-photos/</guid>
		<description><![CDATA[1, getting motors from a typewriter. that&#8217;s where our motors come.


2, wiring the 2 stepper motors. Both of them areunipolar.
The unipolar stepper motor has five or six wires and four coils (actually two coils divided by center connections on each coil). The center connections of the coils are tied together and used as the power [...]]]></description>
			<content:encoded><![CDATA[<p id="top" /><a href="http://www.flickr.com/photos/beyondmeng/2114429306/" title="DSC02069 by sUch A mAGic woRld, on Flickr">1, getting motors from a typewriter. that&#8217;s where our motors come.<br />
</a></p>
<p><a href="http://www.flickr.com/photos/beyondmeng/2101911412/" title="where our motors come from by sUch A mAGic woRld, on Flickr"><img src="http://farm3.static.flickr.com/2277/2101911412_30530f1083.jpg" alt="where our motors come from" height="375" width="500" /></a></p>
<p>2, wiring the 2 stepper motors. Both of them areunipolar.</p>
<p>The unipolar stepper motor has five or six wires and four coils (actually two coils divided by center connections on each coil). The center connections of the coils are tied together and used as the power connection. They are called unipolar steppers because power always comes in on this one pole. (source: http://www.tigoe.net/pcomp/code/category/code/arduinowiring/51 )</p>
<p><a href="http://www.flickr.com/photos/beyondmeng/2101911156/" title="wiring with transistor array by sUch A mAGic woRld, on Flickr"><img src="http://farm3.static.flickr.com/2395/2101911156_159b4f0ae5.jpg" alt="wiring with transistor array" height="375" width="500" /></a></p>
<p>3, connecting the encoder</p>
<p><a href="http://www.acroname.com/robotics/info/ideas/continuous/continuous.html">http://www.nubotics.com/support/index.html</a></p>
<p><a href="http://www.flickr.com/photos/beyondmeng/2101131295/" title="2 steppers to arduino by sUch A mAGic woRld, on Flickr"><img src="http://farm3.static.flickr.com/2321/2101131295_b8ff12080b.jpg" alt="2 steppers to arduino" height="375" width="500" /></a></p>
<p>4, soldering onto little piece of perfboard to make the plug-in modula on arduino</p>
<p><a href="http://www.flickr.com/photos/beyondmeng/2101911016/" title="encoder by sUch A mAGic woRld, on Flickr"><img src="http://farm3.static.flickr.com/2022/2101911016_a01ba2288d_o.jpg" alt="encoder" height="375" width="500" /></a></p>
<p>5, test the encoder, and we got accurate readings: every rotation of the steppers, the encoder increments &#8220;62&#8243;</p>
<p><a href="http://www.flickr.com/photos/beyondmeng/2101131509/" title="stepper motor's tricky counter by sUch A mAGic woRld, on Flickr"><img src="http://farm3.static.flickr.com/2149/2101131509_e0b35071d7.jpg" alt="stepper motor's tricky counter" height="375" width="500" /></a></p>
<p>6, first version of housing gears, motors and encoder.</p>
<p><a href="http://www.flickr.com/photos/beyondmeng/2101131769/" title="housing first version (thanks to mexico clay ) by sUch A mAGic woRld, on Flickr"><img src="http://farm3.static.flickr.com/2188/2101131769_05ac1c7c38.jpg" alt="housing first version (thanks to mexico clay )" height="379" width="504" /></a></p>
<p>6, final version of housing</p>
<p><a href="http://www.flickr.com/photos/beyondmeng/2114429208/" title="DSC02052 by sUch A mAGic woRld, on Flickr"><img src="http://farm3.static.flickr.com/2034/2114429208_2cd6e5df45.jpg" alt="DSC02052" height="375" width="500" /></a></p>
<p>7, standing up (here is the tricky thing.the gravity made the gears works a little bit different, when moving towards up, like 9 o clock, the pointer stepping may loose steps, so we did re-housing, making it more secure and stable, and checking motors again)</p>
<p><a href="http://www.flickr.com/photos/beyondmeng/2113652909/" title="DSC02066 by sUch A mAGic woRld, on Flickr"><img src="http://farm3.static.flickr.com/2191/2113652909_9890d846aa.jpg" alt="DSC02066" height="500" width="375" /></a></p>
<p>8, spray the face and mount onto the clock.</p>
<p><a href="http://www.flickr.com/photos/beyondmeng/2114429306/" title="DSC02069 by sUch A mAGic woRld, on Flickr"><img src="http://farm3.static.flickr.com/2336/2114429306_32bd1bc70c.jpg" alt="DSC02069" height="500" width="375" /></a></p>
<p><a href="http://www.flickr.com/photos/beyondmeng/2101911412/" title="where our motors come from by sUch A mAGic woRld, on Flickr"></a><br />
<strong><a href="http://flickr.com/photos/beyondmeng/tags/final/">http://flickr.com/photos/beyondmeng/tags/final/</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://itp.nyu.edu/blogs/sid213_cem/2007/12/10/documentation-photos/feed/</wfw:commentRss>
		</item>
		<item>
		<title>code dec 9th</title>
		<link>http://itp.nyu.edu/blogs/sid213_cem/2007/12/10/code-dec-9th/</link>
		<comments>http://itp.nyu.edu/blogs/sid213_cem/2007/12/10/code-dec-9th/#comments</comments>
		<pubDate>Mon, 10 Dec 2007 14:39:51 +0000</pubDate>
		<dc:creator>ml1949</dc:creator>
		
		<category><![CDATA[documentation]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/blogs/sid213_cem/2007/12/10/code-dec-9th/</guid>
		<description><![CDATA[
// Variables for calculating PERIOD and SEX pointers
//float speedPointer();
//#include &#60;avr/pgmspace.h&#62;
int encoder[108];
//PROGMEM prog_uchar encoder[106];
//prog_uchar encoder[106] PROGMEM;
//unsigned char lastEncoder0Pos;
int displayRead;
int lastEncoder0Pos;
unsigned char encoder0Pos;
int steps;
int timePeriod=120;
int passedDays=15;
int cycleCount;
int gear20=18;
int gear24=96;
int delayRate;
int pointerPos=0;
//int sexPoint=0;
//int reading[107];
int initialSteps;
int delayMillis;
int savedMillis;
int ellapsedMillis;
int displayEncoder;
//int lastEncoder0Pos;
int lastChange;
//Variables for communicating to Processing
int firstByte; // value for Period
int secondByte; // value for Initial Date
int serialInArray[3]; // [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />
<p>// Variables for calculating PERIOD and SEX pointers<br />
//float speedPointer();<br />
//#include &lt;avr/pgmspace.h&gt;<br />
int encoder[108];<br />
//PROGMEM prog_uchar encoder[106];<br />
//prog_uchar encoder[106] PROGMEM;<br />
//unsigned char lastEncoder0Pos;<br />
int displayRead;<br />
int lastEncoder0Pos;<br />
unsigned char encoder0Pos;<br />
int steps;</p>
<p>int timePeriod=120;<br />
int passedDays=15;<br />
int cycleCount;<br />
int gear20=18;<br />
int gear24=96;<br />
int delayRate;<br />
int pointerPos=0;<br />
//int sexPoint=0;<br />
//int reading[107];<br />
int initialSteps;<br />
int delayMillis;<br />
int savedMillis;<br />
int ellapsedMillis;<br />
int displayEncoder;<br />
//int lastEncoder0Pos;<br />
int lastChange;</p>
<p>//Variables for communicating to Processing<br />
int firstByte; // value for Period<br />
int secondByte; // value for Initial Date<br />
int serialInArray[3]; // array for storing 3 bytes as they arrive from processing<br />
int serialCount = 0; // for counting the number of bytes received</p>
<p>// ENCODER Variables<br />
#define encoder0PinA  2<br />
#define encoder0PinB  3<br />
//volatile int encoder0Pos = 0;</p>
<p>// Stepper Motor Variables<br />
int counter=0;<br />
#include &lt;Stepper.h&gt;<br />
//Motor Steps for Motor 1<br />
#define motor1Steps 24     // change this depending on the number of steps<br />
// Steps fo motor 2<br />
#define motor2Steps 20                         // per revolution of your motor<br />
// Pins 4 to 7 for Motor 1<br />
#define motorPin1 8<br />
#define motorPin2 9<br />
#define motorPin3 10<br />
#define motorPin4 11<br />
//Pins 8-11 for Motor 2<br />
#define motorPin5 4<br />
#define motorPin6 5<br />
#define motorPin7 6<br />
#define motorPin8 7<br />
// initialize of the Stepper library:<br />
Stepper myStepper(motor1Steps, motorPin1,motorPin2,motorPin3,motorPin4);<br />
Stepper myStepper2(motor2Steps,motorPin5,motorPin6,motorPin7,motorPin8);</p>
<p>void setup() {<br />
// set the motor speed at 60 RPMS:<br />
myStepper.setSpeed(10);<br />
myStepper2.setSpeed(60);</p>
<p>// Initialize the Serial port:<br />
Serial.begin(9600);<br />
//  myStepper.step(10);</p>
<p>//SETUP FOR ENCODER<br />
pinMode(encoder0PinA, INPUT);<br />
digitalWrite(encoder0PinA, HIGH);       // turn on pullup resistor<br />
pinMode(encoder0PinB, INPUT);<br />
digitalWrite(encoder0PinB, HIGH);       // turn on pullup resistor<br />
attachInterrupt(0, doEncoder, CHANGE);  // encoder pin on interrupt 0 - pin 2<br />
Serial.begin (9600);<br />
Serial.println(&#8221;start&#8221;);                // a personal quirk<br />
savedMillis=millis();<br />
initialSteps=-106.67*passedDays/timePeriod;<br />
delayMillis=9.375*timePeriod;<br />
myStepper2.step(int(initialSteps));</p>
<p>Serial.println(initialSteps);<br />
}</p>
<p>void loop() {<br />
lastChange = millis();</p>
<p>/*<br />
if (Serial.available() &gt; 0) {<br />
// read the most recent byte (which will be from 0 to 255)<br />
if(Serial.read()==65){<br />
timePeriod = Serial.read();<br />
passedDays = Serial.read();<br />
}<br />
}<br />
*/<br />
/*<br />
serialInArray[serialCount] = Serial.read(); // read a byte sent by processing<br />
serialCount++;  // increment number of bytes received<br />
if (serialCount &gt; 2 ) {  // when 3 bytes received<br />
firstByte = serialInArray[1]; // get value for PERIOD<br />
secondByte = serialInArray[2]; // get value for INITIAL DATE<br />
serialCount = 0;<br />
}<br />
*/<br />
//delayMillis=1000*gear20*timePeriod/(gear24*motor2Steps);</p>
<p>// delayMillis=0;<br />
// Serial.println(delayMillis);</p>
<p>//+&#8221; &#8220;+delayMillis+&#8221; &#8220;+savedMillis);</p>
<p>ellapsedMillis=millis()-savedMillis;<br />
if(ellapsedMillis&gt;=delayMillis){<br />
// Serial.println(ellapsedMillis);<br />
myStepper2.step(-1);<br />
savedMillis=millis();<br />
pointerPos+=1;<br />
//  if(pointerPos==30){<br />
//    Serial.println(&#8221;pointerPos&#8221;);<br />
//    Serial.println(pointerPos);<br />
//  }</p>
<p>//encoder[pointerPos]=encoder0Pos;<br />
//encoder0Pos=lastEncoder0Pos;<br />
//Serial.println(pointerPos);<br />
// displayEncoder = pgm_read_byte_near(lastEncoder0Pos);<br />
// Serial.println(displayEncoder);</p>
<p>///////// STEPPER1.STEP()</p>
<p>// lastEncoder0Pos = encoder0Pos;<br />
// note the last time the encoder changed:</p>
<p>//lastEncoder0Pos=encoder[pointerPos];<br />
//   if (encoder0Pos != encoder[pointerPos] &amp;&amp; encoder[pointerPos]&gt;0) {<br />
if (encoder[pointerPos]&gt;0)  {<br />
// save the last change in the encoder:<br />
//  if(pointerPos&lt;30){<br />
Serial.println(&#8221;encoder[pointerPos]&#8221; );<br />
Serial.println(encoder[pointerPos]);<br />
//  }<br />
//   Serial.println(&#8221;encoder0Pos&#8221;);<br />
//   Serial.println(encoder0Pos, DEC);<br />
//   Serial.println(&#8221;lastEncoder0Pos&#8221;);<br />
//   Serial.println(lastEncoder0Pos);</p>
<p>steps=int(.375*(-encoder0Pos+encoder[pointerPos]));<br />
Serial.println(steps);<br />
myStepper.step(steps);<br />
}<br />
/*<br />
if(encoder0Pos&gt;lastEncoder0Pos){<br />
steps=int(.375*(64-encoder0Pos+lastEncoder0Pos));<br />
Serial.println(&#8221;steps1&#8243;);<br />
Serial.println(steps);<br />
// Serial.println(.375*(64-encoder0Pos+encoder[pointerPos]));<br />
}else{<br />
steps=int(.375*(lastEncoder0Pos-encoder0Pos));<br />
Serial.println(&#8221;steps2&#8243;);<br />
Serial.println(steps);<br />
//     Serial.println(((encoder[pointerPos]-encoder0Pos));<br />
}</p>
<p>}<br />
*/<br />
if (millis() - lastChange &gt;= delayMillis*0.8) {<br />
//  if (millis() - lastChange &gt;= 1000) {<br />
// save the reading<br />
encoder[pointerPos]=encoder0Pos;<br />
//  Serial.println(&#8221;writingingto&#8221;);<br />
// Serial.println(lastEncoder0Pos);<br />
//prog_uchar encoder[pointerPos]=lastEncoder0Pos;<br />
}<br />
}</p>
<p>if (pointerPos == 106){<br />
cycleCount+=1;<br />
pointerPos=0;<br />
if (cycleCount==3){<br />
myStepper2.step(3);<br />
}<br />
Serial.println(&#8221;cycleCount&#8221;);<br />
}</p>
<p>/*<br />
for (int i=0; i&lt;pointerPos; i++){<br />
encoder[i]=displayRead;<br />
Serial.println(displayRead);<br />
if (displayRead&gt;1 &amp;&amp; i==pointerPos){<br />
if (displayRead != encoder0Pos)<br />
myStepper.step(1);<br />
}<br />
}<br />
*/</p>
<p>/*<br />
for( int i=0; i&lt;pointerPos; i++){<br />
encoder[i]=lastEncoder0Pos;<br />
if (lastEncoder0Pos &gt;0){<br />
if (encoder0Pos != lastEncoder0Pos)<br />
{<br />
myStepper.step(1);<br />
}</p>
<p>}<br />
}</p>
<p>*/<br />
}</p>
<p>void doEncoder(){<br />
if (digitalRead(encoder0PinA) == HIGH) {   // found a low-to-high on channel A<br />
if (digitalRead(encoder0PinB) == LOW) {  // check channel B to see which way<br />
// encoder is turning<br />
encoder0Pos = encoder0Pos - 1;         // CCW<br />
}<br />
else {<br />
encoder0Pos = encoder0Pos + 1;         // CW<br />
}<br />
}<br />
else                                        // found a high-to-low on channel A<br />
{<br />
if (digitalRead(encoder0PinB) == LOW) {   // check channel B to see which way<br />
// encoder is turning<br />
encoder0Pos = encoder0Pos + 1;          // CW<br />
}<br />
else {<br />
encoder0Pos = encoder0Pos - 1;          // CCW<br />
}<br />
}</p>
<p>if(encoder0Pos&gt;64){<br />
encoder0Pos=1;<br />
}<br />
if(encoder0Pos&lt;1){<br />
encoder0Pos=64;<br />
}<br />
// Serial.println (encoder0Pos, DEC);          // debug - remember to comment out<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://itp.nyu.edu/blogs/sid213_cem/2007/12/10/code-dec-9th/feed/</wfw:commentRss>
		</item>
		<item>
		<title>code (final) dec 8th</title>
		<link>http://itp.nyu.edu/blogs/sid213_cem/2007/12/09/code-final-dec-8th/</link>
		<comments>http://itp.nyu.edu/blogs/sid213_cem/2007/12/09/code-final-dec-8th/#comments</comments>
		<pubDate>Sun, 09 Dec 2007 05:04:23 +0000</pubDate>
		<dc:creator>ml1949</dc:creator>
		
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/blogs/sid213_cem/2007/12/09/code-final-dec-8th/</guid>
		<description><![CDATA[// Variables for calculating PERIOD and SEX pointers
//float speedPointer();
//#include &#60;avr/pgmspace.h&#62;
int encoder[106];
//PROGMEM prog_uchar encoder[106];
//prog_uchar encoder[106] PROGMEM;
unsigned char lastEncoder0Pos;
int displayRead;
unsigned char encoder0Pos;
int timePeriod=60;
int passedDays=15;
int cycleCount;
int gear20=18;
int gear24=96;
int delayRate;
int pointerPos=0;
//int sexPoint=0;
//int reading[107];
int initialSteps;
int delayMillis;
int savedMillis;
int ellapsedMillis;
int displayEncoder;
//int lastEncoder0Pos;
int lastChange;
//Variables for communicating to Processing
int firstByte; // value for Period
int secondByte; // value for Initial Date
int serialInArray[3]; // array for [...]]]></description>
			<content:encoded><![CDATA[<p id="top" /><code>// Variables for calculating PERIOD and SEX pointers<br />
//float speedPointer();<br />
//#include &lt;avr/pgmspace.h&gt;<br />
int encoder[106];<br />
//PROGMEM prog_uchar encoder[106];<br />
//prog_uchar encoder[106] PROGMEM;<br />
unsigned char lastEncoder0Pos;<br />
int displayRead;</p>
<p>unsigned char encoder0Pos;<br />
int timePeriod=60;<br />
int passedDays=15;<br />
int cycleCount;<br />
int gear20=18;<br />
int gear24=96;<br />
int delayRate;<br />
int pointerPos=0;<br />
//int sexPoint=0;<br />
//int reading[107];<br />
int initialSteps;<br />
int delayMillis;<br />
int savedMillis;<br />
int ellapsedMillis;<br />
int displayEncoder;<br />
//int lastEncoder0Pos;<br />
int lastChange;</p>
<p>//Variables for communicating to Processing<br />
int firstByte; // value for Period<br />
int secondByte; // value for Initial Date<br />
int serialInArray[3]; // array for storing 3 bytes as they arrive from processing<br />
int serialCount = 0; // for counting the number of bytes received</p>
<p>// ENCODER Variables<br />
#define encoder0PinA  2<br />
#define encoder0PinB  3<br />
//volatile int encoder0Pos = 0;</p>
<p>// Stepper Motor Variables<br />
int counter=0;<br />
#include &lt;Stepper.h&gt;<br />
//Motor Steps for Motor 1<br />
#define motor1Steps 24     // change this depending on the number of steps<br />
// Steps fo motor 2<br />
#define motor2Steps 20                         // per revolution of your motor<br />
// Pins 4 to 7 for Motor 1<br />
#define motorPin1 4<br />
#define motorPin2 5<br />
#define motorPin3 6<br />
#define motorPin4 7<br />
//Pins 8-11 for Motor 2<br />
#define motorPin5 8<br />
#define motorPin6 9<br />
#define motorPin7 10<br />
#define motorPin8 11<br />
// initialize of the Stepper library:<br />
Stepper myStepper(motor1Steps, motorPin1,motorPin2,motorPin3,motorPin4);<br />
Stepper myStepper2(motor2Steps,motorPin5,motorPin6,motorPin7,motorPin8);</p>
<p>void setup() {<br />
// set the motor speed at 60 RPMS:<br />
myStepper.setSpeed(10);<br />
myStepper2.setSpeed(60);</p>
<p>// Initialize the Serial port:<br />
Serial.begin(9600);</p>
<p>//SETUP FOR ENCODER<br />
pinMode(encoder0PinA, INPUT);<br />
digitalWrite(encoder0PinA, HIGH);       // turn on pullup resistor<br />
pinMode(encoder0PinB, INPUT);<br />
digitalWrite(encoder0PinB, HIGH);       // turn on pullup resistor<br />
attachInterrupt(0, doEncoder, CHANGE);  // encoder pin on interrupt 0 - pin 2<br />
Serial.begin (9600);<br />
Serial.println("start");                // a personal quirk<br />
savedMillis=millis();<br />
initialSteps=106.67*passedDays/timePeriod;<br />
myStepper2.step(int(initialSteps));</p>
<p>Serial.println(initialSteps);<br />
}</p>
<p>void loop() {</p>
<p>/*<br />
if (Serial.available() &gt; 0) {<br />
// read the most recent byte (which will be from 0 to 255)<br />
if(Serial.read()==65){<br />
timePeriod = Serial.read();<br />
passedDays = Serial.read();<br />
}<br />
}<br />
*/<br />
/*<br />
serialInArray[serialCount] = Serial.read(); // read a byte sent by processing<br />
serialCount++;  // increment number of bytes received<br />
if (serialCount &gt; 2 ) {  // when 3 bytes received<br />
firstByte = serialInArray[1]; // get value for PERIOD<br />
secondByte = serialInArray[2]; // get value for INITIAL DATE<br />
serialCount = 0;<br />
}<br />
*/<br />
//delayMillis=1000*gear20*timePeriod/(gear24*motor2Steps);<br />
delayMillis=9.375*timePeriod;<br />
// delayMillis=0;<br />
// Serial.println(delayMillis);</p>
<p>//+" "+delayMillis+" "+savedMillis);</p>
<p>ellapsedMillis=millis()-savedMillis;<br />
if(ellapsedMillis&gt;=delayMillis){<br />
// Serial.println(ellapsedMillis);<br />
myStepper2.step(1);<br />
savedMillis=millis();<br />
pointerPos+=1;</p>
<p>//encoder[pointerPos]=encoder0Pos;<br />
//encoder0Pos=lastEncoder0Pos;<br />
Serial.println(pointerPos);<br />
// displayEncoder = pgm_read_byte_near(lastEncoder0Pos);<br />
// Serial.println(displayEncoder);</p>
<p>///////// STEPPER1.STEP()</p>
<p>// getPeriod(savedMillis);</p>
<p>}<br />
if (pointerPos == 106){<br />
cycleCount+=1;<br />
pointerPos=0;<br />
if (cycleCount==3){<br />
myStepper2.step(3);<br />
}<br />
Serial.println("cycleCount");<br />
}<br />
// Serial.println(cycleCount);</p>
<p>for (int i=0; i&lt;pointerPos; i++){<br />
encoder[i]=displayRead;<br />
Serial.println(displayRead);<br />
if (displayRead&gt;1 &amp;&amp; i==pointerPos){<br />
if (displayRead != encoder0Pos)<br />
myStepper.step(1);<br />
}<br />
}<br />
}</p>
<p>void doEncoder(){<br />
encoder[pointerPos]=encoder0Pos;<br />
if (digitalRead(encoder0PinA) == HIGH) {   // found a low-to-high on channel A<br />
if (digitalRead(encoder0PinB) == LOW) {  // check channel B to see which way<br />
// encoder is turning<br />
encoder0Pos = encoder0Pos - 1;         // CCW<br />
}<br />
else {<br />
encoder0Pos = encoder0Pos + 1;         // CW<br />
}<br />
}<br />
else                                        // found a high-to-low on channel A<br />
{<br />
if (digitalRead(encoder0PinB) == LOW) {   // check channel B to see which way<br />
// encoder is turning<br />
encoder0Pos = encoder0Pos + 1;          // CW<br />
}<br />
else {<br />
encoder0Pos = encoder0Pos - 1;          // CCW<br />
}<br />
}</p>
<p>if(encoder0Pos&gt;64){<br />
encoder0Pos=1;<br />
}<br />
if(encoder0Pos&lt;1){<br />
encoder0Pos=64;<br />
}</p>
<p>/*<br />
if (encoder0Pos != lastEncoder0Pos) {<br />
// save the last change in the encoder:<br />
lastEncoder0Pos = encoder0Pos;<br />
// note the last time the encoder changed:<br />
lastChange = millis();<br />
}</p>
<p>if (millis() - lastChange &gt;= 1) {<br />
// save the reading<br />
encoder[pointerPos]=encoder0Pos;<br />
// Serial.println(lastEncoder0Pos);<br />
//prog_uchar encoder[pointerPos]=lastEncoder0Pos;<br />
}</p>
<p>*/</p>
<p>// Serial.println (encoder0Pos, DEC);          // debug - remember to comment out</p>
<p>// before final program run<br />
}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://itp.nyu.edu/blogs/sid213_cem/2007/12/09/code-final-dec-8th/feed/</wfw:commentRss>
		</item>
		<item>
		<title>clock face for print</title>
		<link>http://itp.nyu.edu/blogs/sid213_cem/2007/12/07/clock-face-for-print/</link>
		<comments>http://itp.nyu.edu/blogs/sid213_cem/2007/12/07/clock-face-for-print/#comments</comments>
		<pubDate>Fri, 07 Dec 2007 19:26:01 +0000</pubDate>
		<dc:creator>ml1949</dc:creator>
		
		<category><![CDATA[documentation]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/blogs/sid213_cem/2007/12/07/clock-face-for-print/</guid>
		<description><![CDATA[http://itp.nyu.edu/~ml1949/Untitled-12moon%20copy.png
http://itp.nyu.edu/~ml1949/Untitled-1moon%20copy.png
http://itp.nyu.edu/~ml1949/Untitled-13moon%20copy.png
]]></description>
			<content:encoded><![CDATA[<p id="top" /><a href="http://itp.nyu.edu/~ml1949/Untitled-12moon%20copy.png">http://itp.nyu.edu/~ml1949/Untitled-12moon%20copy.png</a></p>
<p><a href="http://itp.nyu.edu/~ml1949/Untitled-1moon%20copy.png">http://itp.nyu.edu/~ml1949/Untitled-1moon%20copy.png</a></p>
<p><a href="http://itp.nyu.edu/~ml1949/Untitled-13moon%20copy.png">http://itp.nyu.edu/~ml1949/Untitled-13moon%20copy.png</a></p>
]]></content:encoded>
			<wfw:commentRss>http://itp.nyu.edu/blogs/sid213_cem/2007/12/07/clock-face-for-print/feed/</wfw:commentRss>
		</item>
		<item>
		<title>code</title>
		<link>http://itp.nyu.edu/blogs/sid213_cem/2007/12/06/code/</link>
		<comments>http://itp.nyu.edu/blogs/sid213_cem/2007/12/06/code/#comments</comments>
		<pubDate>Fri, 07 Dec 2007 01:35:45 +0000</pubDate>
		<dc:creator>sid213</dc:creator>
		
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/blogs/sid213_cem/2007/12/06/code/</guid>
		<description><![CDATA[http://itp.nyu.edu/~sid213/pcom/code.zip
]]></description>
			<content:encoded><![CDATA[<p id="top" /><a href="http://itp.nyu.edu/~sid213/pcom/code.zip">http://itp.nyu.edu/~sid213/pcom/code.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://itp.nyu.edu/blogs/sid213_cem/2007/12/06/code/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Arduino Code by Dec. 5</title>
		<link>http://itp.nyu.edu/blogs/sid213_cem/2007/12/05/29/</link>
		<comments>http://itp.nyu.edu/blogs/sid213_cem/2007/12/05/29/#comments</comments>
		<pubDate>Thu, 06 Dec 2007 01:04:58 +0000</pubDate>
		<dc:creator>sid213</dc:creator>
		
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/blogs/sid213_cem/2007/12/05/29/</guid>
		<description><![CDATA[
// Variables for calculating PERIOD and SEX pointers
float speedPointer();
int gear20=18;
int gear24=96;
int delayRate;
int pointerPos=0;
int sexPoint=0;
int reading[107];
int initialSteps;
//Variables for communicating to Processing
int firstByte; // value for Period
int secondByte; // value for Initial Date
int serialInArray[3]; // array for storing 3 bytes as they arrive from processing
int serialCount = 0; // for counting the number of bytes received
// ENCODER [...]]]></description>
			<content:encoded><![CDATA[<p id="top" /><code><br />
// Variables for calculating PERIOD and SEX pointers<br />
float speedPointer();<br />
int gear20=18;<br />
int gear24=96;<br />
int delayRate;<br />
int pointerPos=0;<br />
int sexPoint=0;<br />
int reading[107];<br />
int initialSteps;</p>
<p>//Variables for communicating to Processing<br />
int firstByte; // value for Period<br />
int secondByte; // value for Initial Date<br />
int serialInArray[3]; // array for storing 3 bytes as they arrive from processing<br />
int serialCount = 0; // for counting the number of bytes received</p>
<p>// ENCODER Variables<br />
#define encoder0PinA  2<br />
#define encoder0PinB  3<br />
volatile int encoder0Pos = 0;</p>
<p>// Stepper Motor Variables<br />
int counter=0;<br />
#include<br />
//Motor Steps for Motor 1<br />
#define motor1Steps 24     // change this depending on the number of steps<br />
// Steps fo motor 2<br />
#define motor2Steps 20                         // per revolution of your motor<br />
// Pins 4 to 7 for Motor 1<br />
#define motorPin1 4<br />
#define motorPin2 5<br />
#define motorPin3 6<br />
#define motorPin4 7<br />
//Pins 8-11 for Motor 2<br />
#define motorPin5 8<br />
#define motorPin6 9<br />
#define motorPin7 10<br />
#define motorPin8 11<br />
// initialize of the Stepper library:<br />
Stepper myStepper(motor1Steps, motorPin1,motorPin2,motorPin3,motorPin4);<br />
Stepper myStepper2(motor2Steps,motorPin5,motorPin6,motorPin7,motorPin8);</p>
<p>void setup() {<br />
// set the motor speed at 60 RPMS:<br />
myStepper.setSpeed(10);<br />
myStepper2.setSpeed(60);</p>
<p>// Initialize the Serial port:<br />
Serial.begin(9600);</p>
<p>//SETUP FOR ENCODER<br />
pinMode(encoder0PinA, INPUT);<br />
digitalWrite(encoder0PinA, HIGH);       // turn on pullup resistor<br />
pinMode(encoder0PinB, INPUT);<br />
digitalWrite(encoder0PinB, HIGH);       // turn on pullup resistor<br />
attachInterrupt(0, doEncoder, CHANGE);  // encoder pin on interrupt 0 - pin 2<br />
Serial.begin (9600);<br />
Serial.println("start");                // a personal quirk<br />
}</p>
<p>void loop() {<br />
if (Serial.available() &gt; 0) {</p>
<p>serialInArray[serialCount] = Serial.read(); // read a byte sent by processing<br />
serialCount++;  // increment number of bytes received<br />
if (serialCount &gt; 2 ) {  // when 3 bytes received<br />
firstByte = serialInArray[1]; // get value for PERIOD<br />
secondByte = serialInArray[2]; // get value for INITIAL DATE<br />
serialCount = 0;<br />
}<br />
}<br />
delayRate=24*60*60*1000*gear20*firstByte/gear24/motor2Steps;<br />
}</p>
<p>void getPeriod(){<br />
int cycleCount;<br />
delay(delayRate);<br />
myStepper2.step(1);<br />
pointerPos+=1<br />
if (pointerPos == 106){<br />
cycleCount+=1;<br />
pointerPos=0<br />
if (cycleCount==3){<br />
myStepper2.step(3);<br />
}<br />
}<br />
}</p>
<p>void setInitialPosforPeriodPointer(int timePeriod, int passedDays){<br />
intialSteps[equal tongue]assedDays*gear24*motor2Steps/timePeriod/gear20;<br />
myStepper2.step(initialSteps);<br />
}</p>
<p>void getRead(){<br />
if (digitalRead(encoder0PinA) == HIGH) {   // found a low-to-high on channel A<br />
for (int i=0, i1 &amp;&amp; i=PointerPos){<br />
if (displayRead != enconder0Pos)<br />
myStepper2.step(1);<br />
}<br />
}<br />
}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://itp.nyu.edu/blogs/sid213_cem/2007/12/05/29/feed/</wfw:commentRss>
		</item>
		<item>
		<title>arduino code</title>
		<link>http://itp.nyu.edu/blogs/sid213_cem/2007/12/04/arduino-code/</link>
		<comments>http://itp.nyu.edu/blogs/sid213_cem/2007/12/04/arduino-code/#comments</comments>
		<pubDate>Tue, 04 Dec 2007 15:53:07 +0000</pubDate>
		<dc:creator>sid213</dc:creator>
		
		<category><![CDATA[documentation]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/blogs/sid213_cem/2007/12/04/arduino-code/</guid>
		<description><![CDATA[/*
 Stepper Motor Controller
 language: Wiring/Arduino
 This program drives a unipolar or bipolar stepper motor.
 The motor is attached to digital pins 8 and 9 of the Arduino.
 The motor moves 100 steps in one direction, then 100 in the other.
 Created 11 Mar. 2007
 Modified 7 Apr. 2007
 by Tom Igoe
 */
// define the [...]]]></description>
			<content:encoded><![CDATA[<p id="top" /><code>/*<br />
 Stepper Motor Controller<br />
 language: Wiring/Arduino</p>
<p> This program drives a unipolar or bipolar stepper motor.<br />
 The motor is attached to digital pins 8 and 9 of the Arduino.</p>
<p> The motor moves 100 steps in one direction, then 100 in the other.</p>
<p> Created 11 Mar. 2007<br />
 Modified 7 Apr. 2007<br />
 by Tom Igoe</p>
<p> */</p>
<p>// define the pins that the motor is attached to. You can use<br />
// any digital I/O pins.<br />
int inByte = 0;<br />
#include </p>
<p>#define motorSteps 48     // change this depending on the number of steps<br />
                           // per revolution of your motor<br />
#define motorPin1 8<br />
#define motorPin2 9<br />
#define motorPin3 10<br />
#define motorPin4 11<br />
#define ledPin 13</p>
<p>// initialize of the Stepper library:<br />
Stepper myStepper(motorSteps, motorPin1,motorPin2,motorPin3,motorPin4); </p>
<p>void setup() {<br />
  // set the motor speed at 60 RPMS:<br />
myStepper.setSpeed(120);</p>
<p>  // Initialize the Serial port:<br />
  Serial.begin(9600);</p>
<p>  // set up the LED pin:<br />
}</p>
<p>void loop() {<br />
  // Step forward 100 steps:<br />
    if (Serial.available() &gt; 0) {<br />
    // get incoming byte:<br />
  inByte = Serial.read();<br />
 // Serial.println("Forward");<br />
//  Serial.print(BYTE);</p>
<p>}<br />
 myStepper.step(inByte);<br />
  delay(500);<br />
}</p>
<p>/*<br />
 Stepper Motor Controller<br />
 language: Wiring/Arduino</p>
<p> This program drives a unipolar or bipolar stepper motor.<br />
 The motor is attached to digital pins 8 and 9 of the Arduino.</p>
<p> The motor moves 100 steps in one direction, then 100 in the other.</p>
<p> Created 11 Mar. 2007<br />
 Modified 7 Apr. 2007<br />
 by Tom Igoe</p>
<p> */</p>
<p>// define the pins that the motor is attached to. You can use<br />
// any digital I/O pins.</p>
<p>#include </p>
<p>#define motorSteps 200     // change this depending on the number of steps<br />
                           // per revolution of your motor<br />
#define motorPin1 8<br />
#define motorPin2 9<br />
#define ledPin 13</p>
<p>// initialize of the Stepper library:<br />
Stepper myStepper(motorSteps, motorPin1,motorPin2); </p>
<p>void setup() {<br />
  // set the motor speed at 60 RPMS:<br />
  myStepper.setSpeed(60);</p>
<p>  // Initialize the Serial port:<br />
  Serial.begin(9600);</p>
<p>  // set up the LED pin:<br />
  pinMode(ledPin, OUTPUT);<br />
  // blink the LED:<br />
  blink(3);<br />
}</p>
<p>}</p>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://itp.nyu.edu/blogs/sid213_cem/2007/12/04/arduino-code/feed/</wfw:commentRss>
		</item>
		<item>
		<title>clock</title>
		<link>http://itp.nyu.edu/blogs/sid213_cem/2007/12/04/clock/</link>
		<comments>http://itp.nyu.edu/blogs/sid213_cem/2007/12/04/clock/#comments</comments>
		<pubDate>Tue, 04 Dec 2007 15:51:16 +0000</pubDate>
		<dc:creator>sid213</dc:creator>
		
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/blogs/sid213_cem/2007/12/04/clock/</guid>
		<description><![CDATA[clock code
]]></description>
			<content:encoded><![CDATA[<p id="top" /><a href="http://itp.nyu.edu/~sid213/icm/periodClock_Serial_NOv28/applet/index.html">clock code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://itp.nyu.edu/blogs/sid213_cem/2007/12/04/clock/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
