<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Decker - Micro</title>
	<atom:link href="http://deckermicro.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://deckermicro.wordpress.com</link>
	<description>SAIC Digital Control:Microcontollers course</description>
	<lastBuildDate>Sat, 21 May 2011 08:41:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='deckermicro.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Decker - Micro</title>
		<link>http://deckermicro.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://deckermicro.wordpress.com/osd.xml" title="Decker - Micro" />
	<atom:link rel='hub' href='http://deckermicro.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Handout for Garnet Hertz&#8217; Workshop session</title>
		<link>http://deckermicro.wordpress.com/2011/04/20/handout-for-garnet-hertz-workshop-session/</link>
		<comments>http://deckermicro.wordpress.com/2011/04/20/handout-for-garnet-hertz-workshop-session/#comments</comments>
		<pubDate>Wed, 20 Apr 2011 14:33:50 +0000</pubDate>
		<dc:creator>mitchellfchan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://deckermicro.wordpress.com/?p=363</guid>
		<description><![CDATA[Is on this attached PDF. Hertz Servo Handout<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deckermicro.wordpress.com&amp;blog=9354074&amp;post=363&amp;subd=deckermicro&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Is on this attached PDF. <a href="http://deckermicro.files.wordpress.com/2011/04/saic-hertz-teachinghandout-arduinoservo-20april2011.pdf">Hertz Servo Handout</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deckermicro.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deckermicro.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deckermicro.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deckermicro.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/deckermicro.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/deckermicro.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/deckermicro.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/deckermicro.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deckermicro.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deckermicro.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deckermicro.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deckermicro.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deckermicro.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deckermicro.wordpress.com/363/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deckermicro.wordpress.com&amp;blog=9354074&amp;post=363&amp;subd=deckermicro&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://deckermicro.wordpress.com/2011/04/20/handout-for-garnet-hertz-workshop-session/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd95c060c873189494ebaa1c1df5b77d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mitchellfchan</media:title>
		</media:content>
	</item>
		<item>
		<title>Proposals</title>
		<link>http://deckermicro.wordpress.com/2011/04/13/proposals/</link>
		<comments>http://deckermicro.wordpress.com/2011/04/13/proposals/#comments</comments>
		<pubDate>Wed, 13 Apr 2011 16:28:34 +0000</pubDate>
		<dc:creator>mitchellfchan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://deckermicro.wordpress.com/?p=347</guid>
		<description><![CDATA[Download most of them here. &#8230;oh, and here&#8217;s one more, from Daniel, and another from Justin.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deckermicro.wordpress.com&amp;blog=9354074&amp;post=347&amp;subd=deckermicro&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="attachment_351" class="wp-caption alignright" style="width: 241px"><a href="http://deckermicro.files.wordpress.com/2011/04/jannasketch.jpg"><img class="size-medium wp-image-351" title="Sketch for Janna's proposal" src="http://deckermicro.files.wordpress.com/2011/04/jannasketch.jpg?w=231&#038;h=300" alt="" width="231" height="300" /></a><p class="wp-caption-text">Sketch for Janna&#039;s proposal</p></div>
<p>Download most of them <a href="http://mitchellfchan.com/files/allproposals.zip">here</a>.</p>
<p>&#8230;oh, and here&#8217;s one more, from <a href="http://mitchellfchan.com/files/danielfandino.pdf">Daniel</a>, and another from <a href="http://mitchellfchan.com/files/Camouflage.doc">Justin</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deckermicro.wordpress.com/347/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deckermicro.wordpress.com/347/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deckermicro.wordpress.com/347/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deckermicro.wordpress.com/347/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/deckermicro.wordpress.com/347/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/deckermicro.wordpress.com/347/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/deckermicro.wordpress.com/347/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/deckermicro.wordpress.com/347/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deckermicro.wordpress.com/347/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deckermicro.wordpress.com/347/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deckermicro.wordpress.com/347/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deckermicro.wordpress.com/347/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deckermicro.wordpress.com/347/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deckermicro.wordpress.com/347/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deckermicro.wordpress.com&amp;blog=9354074&amp;post=347&amp;subd=deckermicro&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://deckermicro.wordpress.com/2011/04/13/proposals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd95c060c873189494ebaa1c1df5b77d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mitchellfchan</media:title>
		</media:content>

		<media:content url="http://deckermicro.files.wordpress.com/2011/04/jannasketch.jpg?w=231" medium="image">
			<media:title type="html">Sketch for Janna's proposal</media:title>
		</media:content>
	</item>
		<item>
		<title>LCD Internet code</title>
		<link>http://deckermicro.wordpress.com/2011/04/13/lcd-internet-code/</link>
		<comments>http://deckermicro.wordpress.com/2011/04/13/lcd-internet-code/#comments</comments>
		<pubDate>Wed, 13 Apr 2011 14:48:27 +0000</pubDate>
		<dc:creator>mitchellfchan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://deckermicro.wordpress.com/?p=343</guid>
		<description><![CDATA[For this afternoon&#8217;s demo, please download this Processing code: LCD-processing.zip Also, for anyone who&#8217;s trying to reconnect this model of LCD display and you&#8217;ve (understandably) forgotten the wiring, the datasheet for the device is now conveniently located here. LCD display datasheet<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deckermicro.wordpress.com&amp;blog=9354074&amp;post=343&amp;subd=deckermicro&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For this afternoon&#8217;s demo, please download this Processing code: <a href="http://idisk.mac.com/shawndecker-Public/micro/projects/LCD-processing.zip">LCD-processing.zip</a></p>
<p>Also, for anyone who&#8217;s trying to reconnect this model of LCD display and you&#8217;ve (understandably) forgotten the wiring, the datasheet for the device is now conveniently located here. <a href="http://deckermicro.files.wordpress.com/2011/04/lcd-display-datasheet.pdf">LCD display datasheet</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deckermicro.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deckermicro.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deckermicro.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deckermicro.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/deckermicro.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/deckermicro.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/deckermicro.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/deckermicro.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deckermicro.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deckermicro.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deckermicro.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deckermicro.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deckermicro.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deckermicro.wordpress.com/343/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deckermicro.wordpress.com&amp;blog=9354074&amp;post=343&amp;subd=deckermicro&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://deckermicro.wordpress.com/2011/04/13/lcd-internet-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd95c060c873189494ebaa1c1df5b77d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mitchellfchan</media:title>
		</media:content>
	</item>
		<item>
		<title>April 6: STEPS</title>
		<link>http://deckermicro.wordpress.com/2011/04/06/april-6-steps/</link>
		<comments>http://deckermicro.wordpress.com/2011/04/06/april-6-steps/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 18:04:35 +0000</pubDate>
		<dc:creator>mitchellfchan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://deckermicro.wordpress.com/?p=339</guid>
		<description><![CDATA[In today&#8217;s code, we&#8217;re using the arduino&#8217;s Stepper Library and arrays to make our stepper motors move according to fixed patterns. This afternoon&#8217;s PRO CHALLENGE: Store 5 different patterns in arrays. Make the code choose randomly which patterns to follow. For this afternoon&#8217;s code, click &#8220;Read More&#8221; // using arrays to store patterns #include &#60;Stepper.h&#62; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deckermicro.wordpress.com&amp;blog=9354074&amp;post=339&amp;subd=deckermicro&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In today&#8217;s code, we&#8217;re using the arduino&#8217;s Stepper Library and arrays to make our stepper motors move according to fixed patterns.</p>
<p><em>This afternoon&#8217;s PRO CHALLENGE:</em></p>
<p>Store 5 different patterns in arrays. Make the code choose randomly which patterns to follow.</p>
<p>For this afternoon&#8217;s code, click &#8220;Read More&#8221;</p>
<p><span id="more-339"></span></p>
<pre>//   using arrays to store patterns</pre>
<pre>#include &lt;Stepper.h&gt;</pre>
<pre>#define NUM_STEPS 48</pre>
<pre>int steps1[11] =  { 20,  -5, 30,  20, 10, -10,   2, -10, 2, -10, 0
};</pre>
<pre>int delays1[11] = { 5, 20, 5, 8, 10,  3, 10, 3, 10, 3, 0
};</pre>
<pre>int steps2[5] =  {  10, -20, 5, -30, 0
};</pre>
<pre>int delays2[5] = { 50, 40, 100, 23, 0
};</pre>
<pre>Stepper stepper(NUM_STEPS, 2,3,4,5);</pre>
<pre>void setup(){
stepper.setSpeed(180);
}</pre>
<pre>void loop(){</pre>
<pre>play_arrays(steps1, delays1);
delay(500);
play_arrays(steps2, delays2);
delay(500);</pre>
<pre>}</pre>
<pre>void play_arrays(int step_array[], int delay_array[]){
int i;</pre>
<pre>for(i=0; i&lt;1000; i++){     //  arbitrariy decide 1000 is larget sequence we will play</pre>
<pre>if(step_array[i] == 0 || delay_array[i] == 0){
break;
}
step_motor(step_array[i], delay_array[i]);
}
}</pre>
<pre>void step_motor(int step_count, int step_delay){
int counter;
int turn_amt;
int turn_dir;</pre>
<pre>turn_amt = abs(step_count);  // get post number of steps</pre>
<pre>if(step_count &gt; 0){          // get direction to go, either -1 or 1
turn_dir = 1;
}
else{
turn_dir = -1;
}</pre>
<pre>for(counter = 0; counter &lt; turn_amt; counter++){   //  loop num of steps times...
stepper.step(turn_dir);   // step either CW/CCW dep. on 1/-1
delay(step_delay);
}</pre>
<pre>}</pre>
<pre>
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deckermicro.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deckermicro.wordpress.com/339/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deckermicro.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deckermicro.wordpress.com/339/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/deckermicro.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/deckermicro.wordpress.com/339/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/deckermicro.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/deckermicro.wordpress.com/339/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deckermicro.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deckermicro.wordpress.com/339/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deckermicro.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deckermicro.wordpress.com/339/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deckermicro.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deckermicro.wordpress.com/339/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deckermicro.wordpress.com&amp;blog=9354074&amp;post=339&amp;subd=deckermicro&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://deckermicro.wordpress.com/2011/04/06/april-6-steps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd95c060c873189494ebaa1c1df5b77d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mitchellfchan</media:title>
		</media:content>
	</item>
		<item>
		<title>March 30th</title>
		<link>http://deckermicro.wordpress.com/2011/03/30/march-30th/</link>
		<comments>http://deckermicro.wordpress.com/2011/03/30/march-30th/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 14:31:49 +0000</pubDate>
		<dc:creator>mitchellfchan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://deckermicro.wordpress.com/?p=333</guid>
		<description><![CDATA[Tom Igoe&#8217;s Website: www.tigoe.net The raw code for controlling a stepper can be found here on the website. &#160;<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deckermicro.wordpress.com&amp;blog=9354074&amp;post=333&amp;subd=deckermicro&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Tom Igoe&#8217;s Website: www.tigoe.net</p>
<p>The raw code for controlling a stepper can be found <a href="http://idisk.mac.com/shawndecker-Public/micro/projects/raw_stepper_example.zip">here</a> on the website.</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deckermicro.wordpress.com/333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deckermicro.wordpress.com/333/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deckermicro.wordpress.com/333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deckermicro.wordpress.com/333/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/deckermicro.wordpress.com/333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/deckermicro.wordpress.com/333/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/deckermicro.wordpress.com/333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/deckermicro.wordpress.com/333/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deckermicro.wordpress.com/333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deckermicro.wordpress.com/333/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deckermicro.wordpress.com/333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deckermicro.wordpress.com/333/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deckermicro.wordpress.com/333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deckermicro.wordpress.com/333/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deckermicro.wordpress.com&amp;blog=9354074&amp;post=333&amp;subd=deckermicro&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://deckermicro.wordpress.com/2011/03/30/march-30th/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd95c060c873189494ebaa1c1df5b77d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mitchellfchan</media:title>
		</media:content>
	</item>
		<item>
		<title>March 23: Code-a-palooza</title>
		<link>http://deckermicro.wordpress.com/2011/03/23/march-23-code-a-palooza/</link>
		<comments>http://deckermicro.wordpress.com/2011/03/23/march-23-code-a-palooza/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 17:53:43 +0000</pubDate>
		<dc:creator>mitchellfchan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://deckermicro.wordpress.com/?p=324</guid>
		<description><![CDATA[Two different sketches today. Click &#8220;read more&#8221; to see them, starting with the random movement sketch, and then continuing with our limit switch demo. // PROJECT 18: MOTOR MAYHEM! // This sketch makes our motor rotate in a random direction, at a random speed, for a random duration. // It uses the motor controller chip [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deckermicro.wordpress.com&amp;blog=9354074&amp;post=324&amp;subd=deckermicro&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Two different sketches today. Click &#8220;read more&#8221; to see them, starting with the random movement sketch, and then continuing with our limit switch demo.</p>
<p><span id="more-324"></span></p>
<pre>// PROJECT 18: MOTOR MAYHEM!
// This sketch makes our motor rotate in a random direction, at a random speed, for a random duration.
// It uses the motor controller chip included in your class kit.
#define A_IN1 5          // motor controller pins
#define A_IN2 4
#define A_PWM 3</pre>
<pre>#define H_SPEED 200
#define L_SPEED 40</pre>
<pre>#define H_DELAY 200
#define L_DELAY 10</pre>
<pre>#define speed_pot 0     // potentiometer</pre>
<pre>void setup(){
pinMode(A_IN1, OUTPUT);
pinMode(A_IN2, OUTPUT);
pinMode(A_PWM, OUTPUT);
}</pre>
<pre>void loop(){
random_speed(L_SPEED, H_SPEED);  // choose a random speed
random_direction();              // choose a random direction
random_delay(L_DELAY, H_DELAY);  // wait a random amount
a_brake();                       // stop
random_delay(L_DELAY, H_DELAY);  // wait a random amount</pre>
<pre>}</pre>
<pre>void a_cw(){
digitalWrite(A_IN1, HIGH);
digitalWrite(A_IN2, LOW);
}</pre>
<pre>void a_ccw(){
digitalWrite(A_IN1, LOW);
digitalWrite(A_IN2, HIGH);
}</pre>
<pre>void a_brake(){
digitalWrite(A_IN1, HIGH);
digitalWrite(A_IN2, HIGH);
}</pre>
<pre>void a_off(){
digitalWrite(A_IN1, LOW);
digitalWrite(A_IN2, LOW);
}</pre>
<pre>void random_speed(int low_val, int high_val){
int r_val;</pre>
<pre>r_val = random(low_val, high_val);
analogWrite(A_PWM, r_val);
}</pre>
<pre>void random_direction(){
int r_val;
r_val = random(2);
if (r_val ==0){
a_cw();
}
else{
a_ccw();
}
}</pre>
<pre>void random_delay(int low_val, int high_val){
int r_val;</pre>
<pre>r_val = random(low_val, high_val);
delay(r_val);
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// THE WORLD'S MOST BORING TENNIS MATCH
// This sketch uses inputs from limit switches to send a motor back and forth, switching directions once
// it hits the switch at the terminus of either direction.

#define A_IN1 5          // motor controller pins
#define A_IN2 4
#define A_PWM 3</pre>
<pre>#define LS 7
#define RS 8</pre>
<pre>#define speed_pot 0     // potentiometer</pre>
<pre>void setup(){
pinMode(A_IN1, OUTPUT);
pinMode(A_IN2, OUTPUT);
pinMode(A_PWM, OUTPUT);
pinMode(LS, INPUT);
pinMode(RS, INPUT);
pinMode(speed_pot, INPUT);
}</pre>
<pre>void loop(){
int a_speed;
int switch_a, switch_b;</pre>
<pre>pot_val = analogRead(speed_pot);
a_speed = map(pot_val, 0, 1024, 20, 230);</pre>
<pre>analogWrite(A_PWM, a_speed);  // set speed
switch_a = digitalRead(LS);
switch_b = digitalRead(RS);</pre>
<pre>if (switch_a == 0){
a_cw();
}</pre>
<pre>else if(switch_b == 0){
a_ccw():
}
}</pre>
<pre>}</pre>
<pre>void a_cw(){
digitalWrite(A_IN1, HIGH);
digitalWrite(A_IN2, LOW);
}</pre>
<pre>void a_ccw(){
digitalWrite(A_IN1, LOW);
digitalWrite(A_IN2, HIGH);
}</pre>
<pre>void a_brake(){
digitalWrite(A_IN1, HIGH);
digitalWrite(A_IN2, HIGH);
}</pre>
<pre>void a_off(){
digitalWrite(A_IN1, LOW);
digitalWrite(A_IN2, LOW);
}</pre>
<pre>
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deckermicro.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deckermicro.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deckermicro.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deckermicro.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/deckermicro.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/deckermicro.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/deckermicro.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/deckermicro.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deckermicro.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deckermicro.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deckermicro.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deckermicro.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deckermicro.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deckermicro.wordpress.com/324/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deckermicro.wordpress.com&amp;blog=9354074&amp;post=324&amp;subd=deckermicro&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://deckermicro.wordpress.com/2011/03/23/march-23-code-a-palooza/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd95c060c873189494ebaa1c1df5b77d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mitchellfchan</media:title>
		</media:content>
	</item>
		<item>
		<title>March 16th: In Review</title>
		<link>http://deckermicro.wordpress.com/2011/03/16/march-16th-in-review/</link>
		<comments>http://deckermicro.wordpress.com/2011/03/16/march-16th-in-review/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 18:27:34 +0000</pubDate>
		<dc:creator>mitchellfchan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://deckermicro.wordpress.com/?p=320</guid>
		<description><![CDATA[Hi All! We made not one, not two, but THREE codes today in class.  All of these codes involve controlling a motor via a TIP122 transistor. For the afternoon, get cracking on mid-term projects. // FIRST SKETCH // a motor cycles between speeding up and slowing down. Input from a potentiometer // controls the rate [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deckermicro.wordpress.com&amp;blog=9354074&amp;post=320&amp;subd=deckermicro&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi All! We made not one, not two, but THREE codes today in class.  All of these codes involve controlling a motor via a TIP122 transistor.</p>
<p>For the afternoon, get cracking on mid-term projects.</p>
<p><span id="more-320"></span></p>
<pre>// FIRST SKETCH
// a motor cycles between speeding up and slowing down. Input from a potentiometer
// controls the rate at which this acceleration/decelration occurs</pre>
<pre>#define MOTOR 3
#define POT 0</pre>
<pre>void setup(){
pinMode(MOTOR, OUTPUT);
}</pre>
<pre>void loop(){
int motor_speed;
int pot_val;
int acceleration;     // how fast the motor speeds up or slows down</pre>
<pre>for (motor_speed = 0; motor_speed &lt; 255; motor_speed++){
analogWrite(MOTOR, motor_speed);
// update acceleration value from potentiometer
pot_val = analogRead(POT);
acceleration = map(pot_val, 0, 1024, 5, 50);
delay(acceleration);
}</pre>
<pre>for (motor_speed = 255; motor_speed &gt; 0; motor_speed--){
analogWrite(MOTOR, motor_speed);
// update acceleration value from potentiometer
pot_val = analogRead(POT);
acceleration = map(pot_val, 0, 1024, 5, 50);
delay(acceleration);
}</pre>
<pre>}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

// SECOND SKETCH
// this simple sketch controls the speed of the motor directly from
// the potentiometer knob

define POT 0

define MOTOR 3

void setup(){

pinMode(MOTOR, OUTPUT);

}

void loop(){

int motor_speed;

int pot_val;

pot_val = analogRead(POT;

motor_speed = map(pot_val, 0, 1024, 70, 230);

analogWrite(MOTOR,motor_speed);

}
//XXXXXXXXXXXXXXXXXXXXX

//THIRD SKETCH

// utilizes the random function to make our motor randomly accelerate

// or decelerate

 

#define MOTOR 3

int motor_speed = 128;

 

 

void setup(){

pinMode(MOTOR, OUTPUT);

 

 

}

 

void loop(){

int change_amt;

int random_num;

 

 

random_num = random(1000);

change_amt = map(random_num, 0, 1000, -5, 5);

motor_speed = (motor_speed + change_amt);

motor_speed = constrain(motor_speed, 0, 255);

delay(20);

analogWrite(MOTOR, motor_speed);

 

}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deckermicro.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deckermicro.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deckermicro.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deckermicro.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/deckermicro.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/deckermicro.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/deckermicro.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/deckermicro.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deckermicro.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deckermicro.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deckermicro.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deckermicro.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deckermicro.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deckermicro.wordpress.com/320/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deckermicro.wordpress.com&amp;blog=9354074&amp;post=320&amp;subd=deckermicro&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://deckermicro.wordpress.com/2011/03/16/march-16th-in-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd95c060c873189494ebaa1c1df5b77d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mitchellfchan</media:title>
		</media:content>
	</item>
		<item>
		<title>March 9th in Review</title>
		<link>http://deckermicro.wordpress.com/2011/03/09/march-9th-in-review/</link>
		<comments>http://deckermicro.wordpress.com/2011/03/09/march-9th-in-review/#comments</comments>
		<pubDate>Wed, 09 Mar 2011 19:13:01 +0000</pubDate>
		<dc:creator>mitchellfchan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://deckermicro.wordpress.com/?p=314</guid>
		<description><![CDATA[As usual, our code from the morning is posted beneath the break. From here, we&#8217;re taking on Project 12 under the &#8220;Projects&#8221; heading of this site: Using a colored RGB LED, connect each of the pins of the LED to three pins on the Arudino that supports PWM.  Now, construct a color mixer that varies [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deckermicro.wordpress.com&amp;blog=9354074&amp;post=314&amp;subd=deckermicro&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As usual, our code from the morning is posted beneath the break.</p>
<p>From here, we&#8217;re taking on Project 12 under the &#8220;Projects&#8221; heading of this site:</p>
<blockquote><p>Using a colored RGB LED, connect each of the pins of the LED to three  pins on the Arudino that supports PWM.  Now, construct a color mixer  that varies the levels of Red, Green and Blue the LED displays using  three potentiometers connected to pins 0, 1, and 2 of the board.  This  essentially uses the ideas brought forward in Project 8, but applying  them to three pins of a colored LED rather than a single pin.</p></blockquote>
<p>Also note that there were two concepts we covered this morning that are <em>not</em> presented here in the code. These were two different ways of creating conditional loops:</p>
<ul>
<li><a href="http://arduino.cc/en/Reference/For">The &#8220;for&#8221; statement</a></li>
<li><a href="http://arduino.cc/en/Reference/While">The &#8220;while&#8221; statement</a></li>
</ul>
<p>Have fun!</p>
<p><span id="more-314"></span></p>
<pre>#define LED1_B 3

#define LED1_G 5

#define LED1_R 6

int red_val, green_val, blue_val;    //current value of the LEDs 0-255

int red_inc, green_inc, blue_inc;    //amount to change each value per loop

int mapped_pwm;                      //vale of LEDs scaled down to useable levels

void setup()

{

pinMode(LED1_B, OUTPUT);

pinMode(LED1_G, OUTPUT);

pinMode(LED1_R, OUTPUT);

red_val = 0;                      //starting values

green_val = 0;

blue_val = 0;

red_inc = 4;                      //amount to change

green_inc = 1;

blue_inc = -2;

}

void loop()

{

red_val += red_inc;              //add increment to the LED values

green_val += green_inc;

blue_val += blue_inc;

if(red_val&gt;255){

red_val = 0;

}

if(blue_val&gt;255){

blue_val = 0;

}

if(green_val&gt;255){

green_val = 0;

}

if(red_val&lt;0){

red_val = 255;

}

if(blue_val&lt;0){

blue_val = 255;

}

if(green_val&lt;0){

green_val = 255;

}

rgb_led(red_val, green_val, blue_val, LED1_R, LED1_G, LED1_B);

delay(20);     // wait a little bit. This controls how fast everything happens

}

void rgb_led (int red, int green, int blue, int red_pin, int green_pin, int blue_pin)

{

mapped_pwm = map(red, 0, 255, 0, 125);

analogWrite(red_pin, mapped_pwm);

mapped_pwm = map(green, 0, 255, 0, 125);

analogWrite(green_pin, mapped_pwm);

mapped_pwm = map(blue, 0, 255, 0, 125);

analogWrite(blue_pin, mapped_pwm);

}</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deckermicro.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deckermicro.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deckermicro.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deckermicro.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/deckermicro.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/deckermicro.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/deckermicro.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/deckermicro.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deckermicro.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deckermicro.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deckermicro.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deckermicro.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deckermicro.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deckermicro.wordpress.com/314/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deckermicro.wordpress.com&amp;blog=9354074&amp;post=314&amp;subd=deckermicro&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://deckermicro.wordpress.com/2011/03/09/march-9th-in-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd95c060c873189494ebaa1c1df5b77d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mitchellfchan</media:title>
		</media:content>
	</item>
		<item>
		<title>March 2: This Week in Review</title>
		<link>http://deckermicro.wordpress.com/2011/03/02/march-2-this-week-in-review/</link>
		<comments>http://deckermicro.wordpress.com/2011/03/02/march-2-this-week-in-review/#comments</comments>
		<pubDate>Wed, 02 Mar 2011 19:01:44 +0000</pubDate>
		<dc:creator>mitchellfchan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://deckermicro.wordpress.com/?p=311</guid>
		<description><![CDATA[After the jump, you&#8217;ll find the code we wrote in class this morning. The circuit that accompanies this code has two LEDs (with your standard 220-ohm resister in series) attached to pin 9 and pin 13. Additionally, we have a 10K potentiometer with the two outer leads going to +5VDC and GND respectively, and the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deckermicro.wordpress.com&amp;blog=9354074&amp;post=311&amp;subd=deckermicro&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After the jump, you&#8217;ll find the code we wrote in class this morning. The circuit that accompanies this code has two LEDs (with your standard 220-ohm resister in series) attached to pin 9 and pin 13. Additionally, we have a 10K potentiometer with the two outer leads going to +5VDC and GND respectively, and the middle lead going to analog in 0.</p>
<p>Note that there are three new concepts here:</p>
<ol>
<li><span style="text-decoration:underline;">Creating our own functions</span>. Here, we create a &#8220;void&#8221; function called &#8220;blink.&#8221; This is a way of keeping a set of actions in one handy section of code, called a function. We can tell the program to jump to that function any time, and it saves us having to write the code out every single time we want to use it. Furthermore, we can pass along certain pieces of information, like values or variables, to use. We do this by including that information in the brackets when we call the function, and defining what we&#8217;ll use it for in the declaration of the function itself. More advanced info on functions at the<a href="http://arduino.cc/en/Reference/FunctionDeclaration"> Arduino Reference</a>.</li>
<li><a href="http://www.arduino.cc/en/Reference/AnalogRead">analogRead</a>. This is a function that only works with the &#8220;analog in&#8221; pins running along one side of the Arduino board. It reads the voltage coming into that pin, and then gives us a number between 0 and 1023, where 1023 would be 5VDC, 512 would be 2.5 VDC, and 0 would be 0 VDC. This process is called Analog-to-Digital-Conversion (ADC).</li>
<li><a href="http://www.arduino.cc/en/Reference/AnalogWrite">analogWrite</a>.  This writes a <a href="http://www.arduino.cc/en/Tutorial/PWM">PWM</a> value to your pin. PWM isn&#8217;t true analog, it&#8217;s faking it. What it really does is turn the pin on and off so fast that we can perceive it as outputing a lower voltage. We can control the &#8220;duty cycle&#8221; (i.e. what percentage of the time it&#8217;s flipped on vs. what percentage of the time it&#8217;s off to give a range of output values. It&#8217;s sort of the equivalent of flashing a white card and a black card at you back and forth really fast to trick you into think you&#8217;re seeing gray. This function only works on the Arduino pins marked with a ~ sign (Uno borads) or the letters PWM (on earlier Arduino boards).</li>
</ol>
<p>For the afternoon, we&#8217;re going to try to make the changes to our code and circuit as outlined on this page: <a href="http://deckermicro.wordpress.com/projects/project-9-potentiometer-controlled-blinker/">Project 9</a>. Post your results in the comments section of that page!</p>
<p><span id="more-311"></span></p>
<pre>#define POT1IN 0    // analog in 0 for pot 1
#define LED 13      // LED is on pin 13
#define PWMOUT 9    // pin for testing PWM output</pre>
<pre>int pot1Val;
int blinkSpeed;
int ledBrightness;</pre>
<pre>void setup()
{
pinMode(LED, OUTPUT);
Serial.begin(9600);
}</pre>
<pre>void loop()
{
pot1Val = analogRead(POT1IN);               // read the incoming pot value
blinkSpeed = map(pot1Val,0,1023,50,500);    // map the incoming pot value to an acceptable range of blinking speeds
ledBrightness = map(pot1Val,0,1023,0,255);  // map the incoming pot value to PWM values between 0 and 255 (this is the full range of numbers that PWM can output)
Serial.print(pot1Val);
Serial.print("   ");
Serial.println(blinkSpeed);
blink(LED, blinkSpeed);                      // call our "blink" function to make one LED blink
analogWrite(PWMOUT, ledBrightness);          // set LED brightness on another LED
}</pre>
<pre>/*
Some people prefer to put a lot of space in here, to keep their functions out of sight from
the rest of the code
*/</pre>
<pre>void blink(int pinNum, int duration)
{
digitalWrite(pinNum, HIGH);
delay(duration);
digitalWrite(pinNum, LOW);
delay(duration);
}</pre>
<pre>
</pre>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deckermicro.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deckermicro.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deckermicro.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deckermicro.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/deckermicro.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/deckermicro.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/deckermicro.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/deckermicro.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deckermicro.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deckermicro.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deckermicro.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deckermicro.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deckermicro.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deckermicro.wordpress.com/311/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deckermicro.wordpress.com&amp;blog=9354074&amp;post=311&amp;subd=deckermicro&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://deckermicro.wordpress.com/2011/03/02/march-2-this-week-in-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd95c060c873189494ebaa1c1df5b77d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mitchellfchan</media:title>
		</media:content>
	</item>
		<item>
		<title>February 23: This Week in Review</title>
		<link>http://deckermicro.wordpress.com/2011/02/23/february-23-this-week-in-review/</link>
		<comments>http://deckermicro.wordpress.com/2011/02/23/february-23-this-week-in-review/#comments</comments>
		<pubDate>Wed, 23 Feb 2011 21:38:35 +0000</pubDate>
		<dc:creator>mitchellfchan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://deckermicro.wordpress.com/?p=305</guid>
		<description><![CDATA[After the jump, you&#8217;ll find a transcription of the program we &#8220;live-coded&#8221; in class today. It&#8217;s one solution to the problem we posed last week: Create a blinking light Arduino program that uses a switch to turn it on and off, and then use two other switches to make the light blink faster or slower. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deckermicro.wordpress.com&amp;blog=9354074&amp;post=305&amp;subd=deckermicro&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After the jump, you&#8217;ll find a transcription of the program we &#8220;live-coded&#8221; in class today. It&#8217;s one solution to the problem we posed last week: Create a blinking light Arduino program that uses a switch to turn it on and off, and then use two other switches to make the light blink faster or slower.</p>
<p>&nbsp;</p>
<p><span style="text-decoration:underline;">THIS WEEK&#8217;S ALL-STAR CHALLENGES</span></p>
<p>If you&#8217;ve worked through this code and feel like you understand it, try to add these wrinkles to your code:</p>
<p>1) Add limits to the blinking rate, so there&#8217;s a maximum and minimum speed (bonus: this will also save your Arduino from crashing when it gets to negative values for delay times)</p>
<p>2) Change the method of speeding up or slowing down the blinking to be more proportional. (i.e.</p>
<p>3) PRO CHALLENGE: Set it up so that the blinking light is, by default, cyclically  speeding up and then slowing down when you turn it on. Then use the two additional buttons to change the rate of speeding up and slowing down.</p>
<p>&nbsp;</p>
<p><span id="more-305"></span></p>
<pre>#define LED_PIN 13            // LED
#define ONOFF_PIN 3           // toggle switch for on/off
#define INCREASE_PIN 4        // switches for inc/dec speed
#define DECREASE_PIN 5
#define ON 1                  // values for on/off variables used in program
#define OFF 0
#define STARTINGSPEED 500
#define SPEED_CHANGE 20

int current_state = LOW;
int previous_state = LOW;
int switch_pressed = OFF;     // did we just see a low/high switch transition?
int led_state = OFF;          // is the LED on?
int blink_speed = STARTINGSPEED;

void setup()
{
 pinMode(LED_PIN, OUTPUT);
 pinMode(ONOFF_PIN, INPUT);
}

void loop()
{

 /* Read the on/off switch */

 current_state = digitalRead(ONOFF_PIN);    // read the input pin

 if ((current_state == HIGH) &amp;&amp; (previous_state == LOW))     // check for ON/OFF transition
 {
 switch_pressed = ON;
 }
 else
 {
 switch_pressed = OFF;
 }

 previous_state = current_state;

 /* read the other switches */

 if(digitalRead(INCREASE_PIN) == HIGH)    // if on, shorten the delay to speed up
 {
 blink_speed = blink_speed - SPEED_CHANGE;
 }

 if(digitalRead(DECREASE_PIN) == HIGH)   // if on, lengthen the delay to slow down
 {
 blink_speed = blink_speed + SPEED_CHANGE;
 }

 /* set the LED state */

 if(switch_pressed == ON)        // if switch was pressed - switch led state
 {
 if(led_state == ON)
 {

 led_state = OFF;
 }
 else
 {

 led_state = ON; 
 }
 }

 if(led_state == ON)              //if led is supposed to be on - then blink the LED
 {
 digitalWrite(LED_PIN, HIGH);
 delay(blink_speed);
 digitalWrite(LED_PIN, LOW);
 delay(blink_speed);
 }

}</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deckermicro.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deckermicro.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deckermicro.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deckermicro.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/deckermicro.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/deckermicro.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/deckermicro.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/deckermicro.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deckermicro.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deckermicro.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deckermicro.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deckermicro.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deckermicro.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deckermicro.wordpress.com/305/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deckermicro.wordpress.com&amp;blog=9354074&amp;post=305&amp;subd=deckermicro&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://deckermicro.wordpress.com/2011/02/23/february-23-this-week-in-review/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd95c060c873189494ebaa1c1df5b77d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mitchellfchan</media:title>
		</media:content>
	</item>
	</channel>
</rss>
