<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Kris Barrett</title>
	
	<link>http://www.krisbarrett.com</link>
	<description>Programming, electronics, and other nerdiness.</description>
	<lastBuildDate>Tue, 08 Nov 2011 16:40:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/krisbarrett" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="krisbarrett" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>How to use JavaScript setTimeout</title>
		<link>http://www.krisbarrett.com/2011/04/14/how-to-use-settimeout-without-pulling-your-hair-out/</link>
		<comments>http://www.krisbarrett.com/2011/04/14/how-to-use-settimeout-without-pulling-your-hair-out/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 01:21:55 +0000</pubDate>
		<dc:creator>Kris</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.krisbarrett.com/?p=150</guid>
		<description><![CDATA[The setTimeout function allows you to delay the execution of code.  The setTimeout function works by specifying a string of code followed by the delay in milliseconds.  For example: setTimeout(&#8220;alert(&#8216;timeout!&#8217;)&#8221;, 1000) The code above will display an alert box that says &#8220;timeout!&#8221; after 1 second (1000 milliseconds).  Because setTimeout uses strings of text that it &#8230; </p><p><a class="more-link block-button" href="http://www.krisbarrett.com/2011/04/14/how-to-use-settimeout-without-pulling-your-hair-out/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p>The setTimeout function allows you to delay the execution of code.  The setTimeout function works by specifying a string of code followed by the delay in milliseconds.  For example:</p>
<blockquote><p>setTimeout(&#8220;alert(&#8216;timeout!&#8217;)&#8221;, 1000)</p></blockquote>
<p>The code above will display an alert box that says &#8220;timeout!&#8221; after 1 second (1000 milliseconds).  Because setTimeout uses strings of text that it tries to execute later, things don&#8217;t always work as expected.  Consider the following example:</p>
<blockquote><p>var test = function() { var obj1 = new Object(); obj1["key"] = &#8220;value&#8221;; setTimeout(&#8216;alert(obj1["key"])&#8217;, 1000); }</p></blockquote>
<p>The code above defines a function called test.  The function creates a new object, sets the attribute &#8220;key&#8221; to &#8220;value&#8221;, and calls setTimeout to display an alert with the value of key 1 second later.  However, calling this function will result in a run-time error because obj1 is outside the scope when the alert function is executed.  To fix this, the code must be written differently:</p>
<blockquote><p>var test = function() { var obj1 = new Object(); obj1["key"] = &#8220;value&#8221;; setTimeout(&#8220;alert(\&#8221;"+obj1["key"]+&#8221;\&#8221;)&#8221;, 1000); }</p></blockquote>
<p>This code works as expected because the value of key is included directly in the string.  The code does not attempt to reference obj1 later.  But, let&#8217;s say you want to pass an entire object to some function.  Simply convert the object to JSON.  For example:</p>
<blockquote><p>var test = function() { var obj1 = new Object(); obj1["key"] = &#8220;value&#8221;; setTimeout(&#8220;some_function(&#8220;+JSON.stringify(obj1)+&#8221;)&#8221;, 1000); }</p></blockquote>
<p>&nbsp;</p>

<p><a href="http://feedads.g.doubleclick.net/~a/e1PEIJO2JK0Q_3oD2oyUN_klYTE/0/da"><img src="http://feedads.g.doubleclick.net/~a/e1PEIJO2JK0Q_3oD2oyUN_klYTE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/e1PEIJO2JK0Q_3oD2oyUN_klYTE/1/da"><img src="http://feedads.g.doubleclick.net/~a/e1PEIJO2JK0Q_3oD2oyUN_klYTE/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.krisbarrett.com/2011/04/14/how-to-use-settimeout-without-pulling-your-hair-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create a git repository</title>
		<link>http://www.krisbarrett.com/2011/03/24/creating-a-git-repository/</link>
		<comments>http://www.krisbarrett.com/2011/03/24/creating-a-git-repository/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 23:22:04 +0000</pubDate>
		<dc:creator>Kris</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://www.krisbarrett.com/?p=147</guid>
		<description><![CDATA[How to create a git repository on your own server: mkdir &#60;dir-name&#62; chown &#60;username&#62;:&#60;git-users-group&#62; &#60;dir-name&#62; chmod g+ws &#60;dir-name&#62; cd &#60;dir-name&#62; git init chmod g+ws .git git config &#8211;bool core.bare true &#160;]]></description>
			<content:encoded><![CDATA[<p>How to create a git repository on your own server:</p>
<blockquote><p>mkdir &lt;dir-name&gt;</p>
<p>chown &lt;username&gt;:&lt;git-users-group&gt; &lt;dir-name&gt;</p>
<p>chmod g+ws &lt;dir-name&gt;</p>
<p>cd &lt;dir-name&gt;</p>
<p>git init</p>
<p>chmod g+ws .git</p>
<p>git config &#8211;bool core.bare true</p>
<p>&nbsp;</p></blockquote>

<p><a href="http://feedads.g.doubleclick.net/~a/pSFNamy2oYR21HTVasGqUuhGLpU/0/da"><img src="http://feedads.g.doubleclick.net/~a/pSFNamy2oYR21HTVasGqUuhGLpU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/pSFNamy2oYR21HTVasGqUuhGLpU/1/da"><img src="http://feedads.g.doubleclick.net/~a/pSFNamy2oYR21HTVasGqUuhGLpU/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.krisbarrett.com/2011/03/24/creating-a-git-repository/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create a MySQL database and user</title>
		<link>http://www.krisbarrett.com/2010/06/12/creating-a-mysql-database-and-user-for-a-web-app/</link>
		<comments>http://www.krisbarrett.com/2010/06/12/creating-a-mysql-database-and-user-for-a-web-app/#comments</comments>
		<pubDate>Sat, 12 Jun 2010 15:38:33 +0000</pubDate>
		<dc:creator>Kris</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.krisbarrett.com/?p=135</guid>
		<description><![CDATA[How to create a MySQL database and user: create database &#60;db_name&#62;; create user &#8216;&#60;user_name&#62;&#8217;@'localhost&#8217; identified by &#8216;&#60;user_password&#62;&#8217;; grant all on &#60;db_name&#62;.* to &#60;user_name&#62;;]]></description>
			<content:encoded><![CDATA[<p>How to create a MySQL database and user:</p>
<blockquote><p>create database &lt;db_name&gt;;</p>
<p>create user &#8216;&lt;user_name&gt;&#8217;@'localhost&#8217; identified by &#8216;&lt;user_password&gt;&#8217;;</p>
<p>grant all on &lt;db_name&gt;.* to &lt;user_name&gt;;</p></blockquote>

<p><a href="http://feedads.g.doubleclick.net/~a/v60o8e6TzW9w9BdD-Z1fPhs9ups/0/da"><img src="http://feedads.g.doubleclick.net/~a/v60o8e6TzW9w9BdD-Z1fPhs9ups/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/v60o8e6TzW9w9BdD-Z1fPhs9ups/1/da"><img src="http://feedads.g.doubleclick.net/~a/v60o8e6TzW9w9BdD-Z1fPhs9ups/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.krisbarrett.com/2010/06/12/creating-a-mysql-database-and-user-for-a-web-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Audio output selector</title>
		<link>http://www.krisbarrett.com/2009/10/22/audio-output-selector/</link>
		<comments>http://www.krisbarrett.com/2009/10/22/audio-output-selector/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 23:10:39 +0000</pubDate>
		<dc:creator>Kris</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[3.5mm jack]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[diy]]></category>
		<category><![CDATA[dpdt]]></category>
		<category><![CDATA[switch]]></category>

		<guid isPermaLink="false">http://www.krisbarrett.com/?p=117</guid>
		<description><![CDATA[Using my headphones with my computer is frustrating.  Whenever I want to use my headphones, I have to move my computer so I can access the back panel, unplug my computer speakers, and plug-in my headphones.  Okay, maybe it isn&#8217;t that difficult, but it should be easier.  How about a device that allows you to &#8230; </p><p><a class="more-link block-button" href="http://www.krisbarrett.com/2009/10/22/audio-output-selector/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/krisbarrett/4036018470/"><img class="alignnone" title="Audio Ouput Selector" src="http://farm3.static.flickr.com/2729/4036018470_f21805a1cf.jpg" alt="" width="500" height="375" /></a></p>
<p>Using my headphones with my computer is frustrating.  Whenever I want to use my headphones, I have to move my computer so I can access the back panel, unplug my computer speakers, and plug-in my headphones.  Okay, maybe it isn&#8217;t <em>that</em> difficult, but it should be easier.  How about a device that allows you to select between headphones or computer speakers?<span id="more-117"></span></p>
<p><strong>Solution</strong></p>
<p>After some careful thought, I realized such a device could be implemented using three 3.5mm jacks and one dual-pole dual-throw (DPDT) switch (see the schematic below).</p>
<p><strong><a href="http://www.krisbarrett.com/wp-content/uploads/2009/10/audio-output-selector.png"><img class="alignnone size-large wp-image-128" style="border: 1px solid black;" title="audio-output-selector" src="http://www.krisbarrett.com/wp-content/uploads/2009/10/audio-output-selector-1024x654.png" alt="audio-output-selector" width="500" height="319" /></a><br />
</strong></p>
<p>As you can see, the DPDT switch simply selects whether the input is connected to the headphones or the computer speakers.</p>
<p><strong>Other Possibilities</strong></p>
<p>A similar device can be implemented using two dual-pole single-throw (DPST) switches.  This would allow the user to select headphones, computer speakers, or both.  A much more sophisticated implementation might include operational amplifiers allowing the user to adjust the gain on each output.</p>
<p><strong><br />
</strong></p>

<p><a href="http://feedads.g.doubleclick.net/~a/ZT6dT49i2qASRiIN8okaOHLx-kk/0/da"><img src="http://feedads.g.doubleclick.net/~a/ZT6dT49i2qASRiIN8okaOHLx-kk/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/ZT6dT49i2qASRiIN8okaOHLx-kk/1/da"><img src="http://feedads.g.doubleclick.net/~a/ZT6dT49i2qASRiIN8okaOHLx-kk/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.krisbarrett.com/2009/10/22/audio-output-selector/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>How to setup AVR projects</title>
		<link>http://www.krisbarrett.com/2009/09/12/first-avr-project/</link>
		<comments>http://www.krisbarrett.com/2009/09/12/first-avr-project/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 22:33:35 +0000</pubDate>
		<dc:creator>Kris</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[avr]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[firmware]]></category>
		<category><![CDATA[led]]></category>

		<guid isPermaLink="false">http://www.krisbarrett.com/?p=103</guid>
		<description><![CDATA[This brief tutorial demonstrates how to create projects for the AVR using AVR-GCC.  This tutorial assumes that you are using Ubuntu for your development environment.  This tutorial also assumes that you have already installed AVRDUDE.  Also, you should have a development board with at least one button and one LED.  In my case, the button &#8230; </p><p><a class="more-link block-button" href="http://www.krisbarrett.com/2009/09/12/first-avr-project/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p>This brief tutorial demonstrates how to create projects for the AVR using AVR-GCC.  This tutorial assumes that you are using Ubuntu for your development environment.  This tutorial also assumes that you have already installed AVRDUDE.  Also, you should have a development board with at least one button and one LED.  In my case, the button is active low.</p>
<p>1. Install AVR-GCC:</p>
<blockquote><p>$ sudo apt-get install gcc-avr<br />
$ sudo apt-get install avr-libc</p></blockquote>
<p>2. Create a new directory for your project, let&#8217;s call it blink:</p>
<blockquote><p>$ mkdir blink<br />
$ cd blink</p></blockquote>
<p>3. Download the template makefile:</p>
<blockquote><p>$ wget http://electrons.psychogenic.com/articles/Makefile.tpl<br />
$ mv Makefile.tpl Makefile</p></blockquote>
<p>4. Copy the template makefile to your Templates folder if desired:</p>
<blockquote><p>$ cp Makefile ~/Templates/avr-makefile</p></blockquote>
<p>5. Modify the configuration section of the makefile.  This is fairly easy thanks to the helpful comments included in the makefile.  I used the following configuration:</p>
<blockquote><p>MCU=atmega128<br />
PROGRAMMER_MCU=m128<br />
PROJECTNAME=blink<br />
PRJSRC=blink.c<br />
INC=<br />
LIBS=<br />
OPTLEVEL=0<br />
AVRDUDE_PROGRAMMERID=dragon_jtag<br />
AVRDUDE_PORT=usb</p></blockquote>
<p>6. Get blink.c:</p>
<blockquote><p>$ wget http://www.krisbarrett.com/wp-content/uploads/2009/09/blink.c</p></blockquote>
<p>7. Modify the #defines so that they correspond to the connections on your development board.  On my development board, the BTN is connected to PA2 and the LED is connected to PA6.</p>
<blockquote><p>#define LED (1 &lt;&lt; PA6)<br />
#define BTN (1 &lt;&lt; PA2)</p></blockquote>
<p>8. Build the project:</p>
<blockquote><p>$ make</p></blockquote>
<p>9. Program the AVR using the writeflash target included in the makefile:</p>
<blockquote><p>$ sudo make writeflash</p></blockquote>
<p>Ensure that the program works as expected.  The LED should turn on when the button is pressed.  The LED should turn off when it is released.  Recall that this assumes your button is active low.  Congratulations, you have just created your first AVR project!</p>

<p><a href="http://feedads.g.doubleclick.net/~a/m6jZ8WDx_pyobb7EAOdzlpTZbjA/0/da"><img src="http://feedads.g.doubleclick.net/~a/m6jZ8WDx_pyobb7EAOdzlpTZbjA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/m6jZ8WDx_pyobb7EAOdzlpTZbjA/1/da"><img src="http://feedads.g.doubleclick.net/~a/m6jZ8WDx_pyobb7EAOdzlpTZbjA/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.krisbarrett.com/2009/09/12/first-avr-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use AVR Dragon</title>
		<link>http://www.krisbarrett.com/2009/09/12/avr-dragon-quick-start/</link>
		<comments>http://www.krisbarrett.com/2009/09/12/avr-dragon-quick-start/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 19:35:44 +0000</pubDate>
		<dc:creator>Kris</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[avr]]></category>
		<category><![CDATA[development tools]]></category>
		<category><![CDATA[firmware]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[jtag]]></category>
		<category><![CDATA[microcontroller]]></category>

		<guid isPermaLink="false">http://www.krisbarrett.com/?p=98</guid>
		<description><![CDATA[This brief tutorial demonstrates how to read, write, and erase an AVR chip using AVR Dragon.  This tutorial assumes that you are using Ubuntu for your development environment.  This tutorial also assumes that you have an AVR development board running a demo program.  The JTAG port is used in this tutorial, but the ISP port &#8230; </p><p><a class="more-link block-button" href="http://www.krisbarrett.com/2009/09/12/avr-dragon-quick-start/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p>This brief tutorial demonstrates how to read, write, and erase an AVR chip using AVR Dragon.  This tutorial assumes that you are using Ubuntu for your development environment.  This tutorial also assumes that you have an AVR development board running a demo program.  The JTAG port is used in this tutorial, but the ISP port can also be used.  Simply replace &#8220;dragon_jtag&#8221; with &#8220;dragon_isp&#8221;.</p>
<p>1. Install AVRDUDE:</p>
<blockquote><p>$ sudo apt-get install avrdude</p></blockquote>
<p>2. Read demo program from development board:</p>
<blockquote><p>$ sudo avrdude -p m128 -c dragon_jtag -P usb -U flash:r:flash.hex:i</p></blockquote>
<p>3. Erase development board:</p>
<blockquote><p>$ sudo avrdude -p m128 -c dragon_jtag -P usb -e</p></blockquote>
<p>4. Reprogram the development board:</p>
<blockquote><p>$ sudo avrdude -p m128 -c dragon_jtag -P usb -U flash:w:flash.hex:i</p></blockquote>

<p><a href="http://feedads.g.doubleclick.net/~a/Y3tasqrypiD-xhlRdKnbBlqe_yg/0/da"><img src="http://feedads.g.doubleclick.net/~a/Y3tasqrypiD-xhlRdKnbBlqe_yg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Y3tasqrypiD-xhlRdKnbBlqe_yg/1/da"><img src="http://feedads.g.doubleclick.net/~a/Y3tasqrypiD-xhlRdKnbBlqe_yg/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.krisbarrett.com/2009/09/12/avr-dragon-quick-start/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Catalan numbers</title>
		<link>http://www.krisbarrett.com/2009/08/30/catalan-numbers/</link>
		<comments>http://www.krisbarrett.com/2009/08/30/catalan-numbers/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 01:16:28 +0000</pubDate>
		<dc:creator>Kris</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[math]]></category>

		<guid isPermaLink="false">http://www.krisbarrett.com/?p=87</guid>
		<description><![CDATA[Recently I was trying to count the number of n-bit numbers that have an equal number of 1&#8242;s and 0&#8242;s.  For example, there are 6 such numbers for 4-bit long numbers (0011, 0101, 0110, 1001, 1010, 1100).  I wrote a simple program to count such numbers for arbitrarily long numbers.  However, the program was computationally &#8230; </p><p><a class="more-link block-button" href="http://www.krisbarrett.com/2009/08/30/catalan-numbers/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-89" title="Image courtesy of Wikipedia" src="http://www.krisbarrett.com/wp-content/uploads/2009/08/690px-Catalan_number_4x4_grid_example.svg.png" alt="690px-Catalan_number_4x4_grid_example.svg" width="500" height="254" /></p>
<p>Recently I was trying to count the number of n-bit numbers that have an equal number of 1&#8242;s and 0&#8242;s.  For example, there are 6 such numbers for 4-bit long numbers (0011, 0101, 0110, 1001, 1010, 1100).  I wrote a simple program to count such numbers for arbitrarily long numbers.  However, the program was computationally complex and it took a long time to compute the result for large values of n.  After spending some time trying to figure out the equation myself, I searched the internet and stumbled upon Catalan numbers.  I determined that the equation is related to Catalan numbers.  I included the equation below because I couldn&#8217;t find it anywhere else.  Also, I don&#8217;t have a formal proof, but it seems to work.  Enjoy!</p>
<p>Number of n-bit numbers that have an equal number of 1&#8242;s and 0&#8242;s = (m+1) * Cm, where m = n/2 and Cm = mth Catalan number</p>

<p><a href="http://feedads.g.doubleclick.net/~a/a1HKiy_gbqdiIUaQ91c4Bn87uk4/0/da"><img src="http://feedads.g.doubleclick.net/~a/a1HKiy_gbqdiIUaQ91c4Bn87uk4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/a1HKiy_gbqdiIUaQ91c4Bn87uk4/1/da"><img src="http://feedads.g.doubleclick.net/~a/a1HKiy_gbqdiIUaQ91c4Bn87uk4/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.krisbarrett.com/2009/08/30/catalan-numbers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to make your own Arduino shield</title>
		<link>http://www.krisbarrett.com/2008/09/03/make-a-custom-arduino-shield/</link>
		<comments>http://www.krisbarrett.com/2008/09/03/make-a-custom-arduino-shield/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 00:47:58 +0000</pubDate>
		<dc:creator>Kris</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[arduino shield]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[diy]]></category>
		<category><![CDATA[eagle]]></category>
		<category><![CDATA[led]]></category>
		<category><![CDATA[pcb]]></category>
		<category><![CDATA[transistor]]></category>

		<guid isPermaLink="false">http://www.krisbarrett.com/2008/09/03/make-a-custom-arduino-shield/</guid>
		<description><![CDATA[After many months of working on my Arduino based project, I decided to finalize my project by making my own custom PCB.  At first I wanted to design a PCB that connected to the Arduino through a series of cables.  After some thought however, I realized that a shield would be better because it would &#8230; </p><p><a class="more-link block-button" href="http://www.krisbarrett.com/2008/09/03/make-a-custom-arduino-shield/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/krisbarrett/2826187914/"></a> <a href="http://www.flickr.com/photos/krisbarrett/2826187914/"><img src="http://farm4.static.flickr.com/3030/2826187914_4ef6f81bfb.jpg?v=0" alt="Arduino Shield" width="500" height="375" /></a></p>
<p>After many months of working on my Arduino based project, I decided to finalize my project by making my own custom PCB.  At first I wanted to design a PCB that connected to the Arduino through a series of cables.  After some thought however, I realized that a shield would be better because it would eliminate the need for cables.  This tutorial assumes an understanding of Cadsoft Eagle.  For more information about Eagle, see the Eagle Tutorials section below.  Here are the steps to make your own Arduino shield:<span id="more-37"></span></p>
<ol>
<li><strong>Part Selection</strong>- Carefully select your parts. Ensure that your parts meet your performance and power requirements.  It is better to carefully choose your parts now, than wish you chose something else later.</li>
<li><strong>Prototype</strong> &#8211; Prototype your design on a breadboard.  Ensure that your functional, performance, and power requirements are being met.  Change your design as necessary.  Do not begin designing the PCB until you are completely satisfied with your prototype.<a href="http://www.flickr.com/photos/krisbarrett/2712458517/in/photostream/"><img src="http://farm4.static.flickr.com/3065/2712458517_a1d41dc70b.jpg?v=0" alt="" width="500" height="375" /></a><br />
<strong>Figure 1:<br />
</strong>Breadboard prototype</li>
<li><strong>Schematic Capture </strong>
<ol>
<li style="list-style-type: lower-alpha;"><strong>Add Custom Parts to Eagle</strong> &#8211; Place all of your parts in the schematic before drawing any wires.  This allows you to identify which parts you will need to create yourself.  I had to create a custom part for the Arduino.  Drawing a symbol for the Arduino was easy.  Drawing the package was a little bit more difficult because I had to determine the spacing between the headers.  I easily obtained this information from the Arduino Eagle files which I downloaded from the Arduino website.  Download my Eagle Arduino library <a href="http://www.krisbarrett.com/arduino.lbr">here</a>.<a href="http://www.flickr.com/photos/krisbarrett/2826317564/"><img src="http://farm4.static.flickr.com/3077/2826317564_28413c8771.jpg?v=0" alt="" width="500" height="392" /></a><br />
<strong>Figure 2:</strong><br />
Header locations relative to one another.  I obtained this information from the Eagle file.</p>
<p><a href="http://farm4.static.flickr.com/3027/2825309347_dff89b099f_o.jpg"><img src="http://farm4.static.flickr.com/3027/2825309347_7b7f2b8aa1.jpg?v=0" alt="" width="500" height="279" /></a><strong><br />
Figure 3:<br />
</strong>Arduino symbol and package that I created in Eagle.</li>
<li style="list-style-type: lower-alpha;"><strong>Connect Parts </strong>- After placing all of your parts in the schematic, carefully connect your parts together using the wire tool.  If you make a mistake on your schematic, it will ultimately show up on your PCB.</li>
</ol>
</li>
<li><strong>PCB Layout </strong>- Place the parts on the board.  If your PCB is long enough, the PCB will rest on top of the USB connector on the Arduino.  Parts and traces should not be placed here because it could potentially short out your PCB.  I accidentally placed the DC power connector in this area. Fortunately,  I was able to insulate the USB connector with a piece of electrical tape.  Also, follow PCB layout guidelines.  I learned this the hard way when I discovered that the rapid switching of the transistors was inducing a voltage in one of the traces connected to the button.<a href="http://www.flickr.com/photos/krisbarrett/2825398079/"> </a><a href="http://www.flickr.com/photos/krisbarrett/2825398079/"><img src="http://farm4.static.flickr.com/3237/2825398079_67bbd3335f.jpg?v=0" alt="" width="500" height="375" /></a><strong><br />
Figure 4</strong>:<br />
I made the mistake of placing a part above the USB connector.  I prevented the part from shorting out by placing some electrical tape on top of the USB connector.</p>
<p><a href="http://www.flickr.com/photos/krisbarrett/2825399045"><img src="http://farm4.static.flickr.com/3235/2825399045_04db0b39b5.jpg?v=0" alt="" width="500" height="375" /><br />
</a><strong>Figure 5: </strong><br />
The shield also doesn&#8217;t sit properly because of my poor layout.</li>
<li><strong>PCB Fabrication</strong> &#8211; Generate the CAM files.  You could fabricate the PCB yourself, but I highly recommend BatchPCB.  BatchPCB fabricates inexpensive, production quality PCBs.  The only drawback is that you have to wait three weeks to a month to receive your order.  BatchPCB has a tutorial on generating the files that they need to fabricate your PCB.<a href="http://www.flickr.com/photos/krisbarrett/2796528389"><img src="http://farm4.static.flickr.com/3108/2796528389_e9960b7935.jpg?v=0" alt="" width="500" height="375" /><br />
</a><strong>Figure 6</strong>:<br />
Final product from BatchPCB.</li>
</ol>
<p><strong>Final Thoughts<br />
</strong>Although I am not happy with the way my PCB turned out, I learned valuable information about PCB design.  I am sure that if I follow PCB layout guidelines, I can get this PCB to work properly.  I hope people can learn from my mistakes on this project and design a better Arduino shield of their own.</p>
<p><strong>Eagle Tutorials</strong><br />
<a href="http://www.sparkfun.com/commerce/tutorial_info.php?tutorials_id=57&amp;sipp=1&amp;page=8">Schematic Capture</a><br />
<a href="http://www.sparkfun.com/commerce/tutorial_info.php?tutorials_id=57&amp;sipp=1&amp;page=10">Creating Custom Parts</a><br />
<a href="http://www.sparkfun.com/commerce/tutorial_info.php?tutorials_id=57&amp;sipp=1&amp;page=9">PCB Layout</a><br />
<a href="http://www.batchpcb.com/eagle-tutorial.php?osCsid=6fafc3f166d30af2bc9598efd0d9c71f">Generating CAM Files</a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/kp-0sp1NotVTRzQ3R0I94F50-2I/0/da"><img src="http://feedads.g.doubleclick.net/~a/kp-0sp1NotVTRzQ3R0I94F50-2I/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/kp-0sp1NotVTRzQ3R0I94F50-2I/1/da"><img src="http://feedads.g.doubleclick.net/~a/kp-0sp1NotVTRzQ3R0I94F50-2I/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.krisbarrett.com/2008/09/03/make-a-custom-arduino-shield/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Fun with FFT</title>
		<link>http://www.krisbarrett.com/2008/08/25/fast-fourier-transform/</link>
		<comments>http://www.krisbarrett.com/2008/08/25/fast-fourier-transform/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 22:55:03 +0000</pubDate>
		<dc:creator>Kris</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[breadboard]]></category>
		<category><![CDATA[fft]]></category>

		<guid isPermaLink="false">http://www.krisbarrett.com/2008/08/25/fast-fourier-transform/</guid>
		<description><![CDATA[This is a project that I threw together one weekend.  The FFT is calculated using Processing. The FFT is then sent to the Freeduino via the serial port. The Freeduino displays the FFT on the dot matrix display using shift registers and a Darlington transistor array.]]></description>
			<content:encoded><![CDATA[<p><object width="500" height="375" type="application/x-shockwave-flash" data="http://www.vimeo.com/moogaloop.swf?clip_id=1601790&amp;server=www.vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.vimeo.com/moogaloop.swf?clip_id=1601790&amp;server=www.vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /></object></p>
<p>This is a project that I threw together one weekend.  The FFT is calculated using <a href="http://www.processing.org">Processing</a>.  The FFT is then sent to the Freeduino via the serial port.  The Freeduino displays the FFT on the dot matrix display using shift registers and a Darlington transistor array.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/uUCV_HSJk5hdKub5mbrE2JTVXjM/0/da"><img src="http://feedads.g.doubleclick.net/~a/uUCV_HSJk5hdKub5mbrE2JTVXjM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/uUCV_HSJk5hdKub5mbrE2JTVXjM/1/da"><img src="http://feedads.g.doubleclick.net/~a/uUCV_HSJk5hdKub5mbrE2JTVXjM/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.krisbarrett.com/2008/08/25/fast-fourier-transform/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Improved light bar controller</title>
		<link>http://www.krisbarrett.com/2008/07/29/improved-light-bar-controller/</link>
		<comments>http://www.krisbarrett.com/2008/07/29/improved-light-bar-controller/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 07:22:25 +0000</pubDate>
		<dc:creator>Kris</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.krisbarrett.com/2008/07/29/improved-light-bar-controller/</guid>
		<description><![CDATA[I made several improvements to my light bar controller.  I added a push button that pauses the controller on a desired color. I added a red LED to indicate if the controller is paused.  I also modified the light bar so that it easily plugs into the breadboard.  I did this by replacing the polarized &#8230; </p><p><a class="more-link block-button" href="http://www.krisbarrett.com/2008/07/29/improved-light-bar-controller/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/28071658@N02/2712458517/"><img src="http://farm4.static.flickr.com/3065/2712458517_a1d41dc70b.jpg?v=0" alt="Improved Light Bar Controller" /></a></p>
<p>I made several improvements to my light bar controller.  I added a push button that pauses the controller on a desired color. I added a red LED to indicate if the controller is paused.  I also modified the light bar so that it easily plugs into the breadboard.  I did this by replacing the polarized right angle connectors with non polarized headers (one straight and one right angle).  The improved controller also uses the Bare Bones Board from the Modern Device Company instead of the Diecimila.  Below is an updated schematic of the controller.<span id="more-35"></span> Get the code <a href="http://www.krisbarrett.com/wp-content/uploads/2008/07/rgb2.c">here</a>.</p>
<p><a href="http://www.flickr.com/photos/28071658@N02/2712530385/in/set-72157606430368078/"><img src="http://farm4.static.flickr.com/3045/2712530385_646806f68a.jpg?v=0" alt="Schematic" /></a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/LyvjTfOM5eHSTrN4ocTMBklW-1s/0/da"><img src="http://feedads.g.doubleclick.net/~a/LyvjTfOM5eHSTrN4ocTMBklW-1s/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/LyvjTfOM5eHSTrN4ocTMBklW-1s/1/da"><img src="http://feedads.g.doubleclick.net/~a/LyvjTfOM5eHSTrN4ocTMBklW-1s/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.krisbarrett.com/2008/07/29/improved-light-bar-controller/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

