<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ben Dauphinee - Blog</title>
	<atom:link href="http://blog.bendauphinee.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bendauphinee.com</link>
	<description></description>
	<lastBuildDate>Sun, 19 Feb 2012 15:40:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Shift The Graph</title>
		<link>http://blog.bendauphinee.com/2012/02/shift-the-graph/</link>
		<comments>http://blog.bendauphinee.com/2012/02/shift-the-graph/#comments</comments>
		<pubDate>Sun, 19 Feb 2012 15:31:40 +0000</pubDate>
		<dc:creator>Ben Dauphinee</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[led]]></category>
		<category><![CDATA[physical]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[shift-register]]></category>

		<guid isPermaLink="false">http://blog.bendauphinee.com/?p=162</guid>
		<description><![CDATA[I have started working with an Arduino. For someone getting started in electronics, this device, and the community around it make it so much easier to learn. Within two minutes of plugging it in and starting the software, I was able to do something. Fast forward a bit, this project is the first big project [...]]]></description>
			<content:encoded><![CDATA[<p>I have started working with an Arduino. For someone getting started in electronics, this device, and the community around it make it so much easier to learn. Within two minutes of plugging it in and starting the software, I was able to do something.</p>
<p>Fast forward a bit, this project is the first big project I have taken on. It is a 10 segment bar graph that I wired up, but now, I am moving it&#8217;s control from the 10 analog pins to some shift registers. This frees up most of the pins that I needed initially, and doesn&#8217;t make control more difficult. </p>
<p>A shift register is like a bucket brigade. Each bucket is one bit on the register, and as you pass it bits, the rest of them get passed one down the line. So, to control which legs of the shift register are powered and which not, I just have to pulse 1&#8242;s and 0&#8242;s into the register until I get it set the way I want. Since the LED segments are controlled by the shift register legs, they&#8217;re set by what is pulsed to the register.</p>
<p>If I want to have an alternating pattern, the registers contain these values</p>
<pre class="brush: plain; title: ; notranslate">   [10101010] -&gt; [10101010]
// Register 1 -&gt; Register 2</pre>
<p>If I were to push one more bit down the line, they would all move one step along.</p>
<pre class="brush: plain; title: ; notranslate">   [01010101] -&gt; [01010101]
// Register 1 -&gt; Register 2</pre>
<p>If I wanted to push the segments to all lit, the register just has to be fed 1&#8242;s.</p>
<pre class="brush: plain; title: ; notranslate">   [11111111] -&gt; [11010101]
// Register 1 -&gt; Register 2</pre>
<p><br clear="both"><br />
<b>Part List</b></p>
<ul>
<li>Arduino</li>
<li>10 x 330&#8486; Resistors</li>
<li>10 Segment LED bar graph or 10 x LED&#8217;s</li>
<li>2 x 74LS164N Shift Registers (or any non-164 shift register, your wiring may be different)</li>
<li>Wires and Breadboards</li>
</ul>
<p><br clear="both"><br />
<b>Notes</b></p>
<ul>
<li>For this project, I&#8217;m not using the reset ability of the 164, so that pin has been tied to V+.</li>
<li>There is an Arduino function called shiftOut() that would make this a little easier. I have not used it because I wanted to shift the bits myself to get a better feel for what it was doing.</li>
<li>To wire the shift registers to the Arduino, it&#8217;s pin 2 on the Arduino to the clock pin (pin 8) on the first or second shift register (since they&#8217;re both wired together), and pin 3 Arduino to data pin (pin 1) on the first shift register.</li>
</ul>
<p><br clear="both"><br />
<a href="http://blog.bendauphinee.com/wp-content/uploads/2012/02/shiftregister.gif"><img src="http://blog.bendauphinee.com/wp-content/uploads/2012/02/shiftregister-150x150.gif" alt="" title="shiftregister" width="100" height="100" class="alignleft size-thumbnail wp-image-198 photo" style="float: left; border: 1px solid #000; margin: 2px;"/></a><a href="http://blog.bendauphinee.com/wp-content/uploads/2012/02/01.jpg"><img src="http://blog.bendauphinee.com/wp-content/uploads/2012/02/01-150x150.jpg" alt="" title="Bar Graph Wiring" width="100" height="100" class="size-thumbnail wp-image-168 photo" style="float: left; border: 1px solid #000; margin: 2px;" /></a><a href="http://blog.bendauphinee.com/wp-content/uploads/2012/02/02.jpg"><img src="http://blog.bendauphinee.com/wp-content/uploads/2012/02/02-150x150.jpg" alt="" title="Shift Register Wiring" width="100" height="100" class="size-thumbnail wp-image-169 photo" style="float: left; border: 1px solid #000; margin: 2px;" /></a><a href="http://blog.bendauphinee.com/wp-content/uploads/2012/02/03.jpg"><img src="http://blog.bendauphinee.com/wp-content/uploads/2012/02/03-150x150.jpg" alt="" title="Partially Connected Bar Graph" width="100" height="100" class="size-thumbnail wp-image-170 photo" style="float: left; border: 1px solid #000; margin: 2px;" /></a><a href="http://blog.bendauphinee.com/wp-content/uploads/2012/02/04.jpg"><img src="http://blog.bendauphinee.com/wp-content/uploads/2012/02/04-150x150.jpg" alt="" title="Bar Graph Wired To Shift Register" width="100" height="100" class="size-thumbnail wp-image-171 photo" style="float: left; border: 1px solid #000; margin: 2px;" /></a><a href="http://blog.bendauphinee.com/wp-content/uploads/2012/02/05.jpg"><img src="http://blog.bendauphinee.com/wp-content/uploads/2012/02/05-150x150.jpg" alt="" title="The Entire Setup Wired To Arduino" width="100" height="100" class="size-thumbnail wp-image-172 photo" style="float: left; border: 1px solid #000; margin: 2px;" /></a></p>
<p><br clear="both"></p>
<pre class="brush: plain; title: ; notranslate">
#define DATA 3
#define CLOCK 2

void setup() {
  pinMode(CLOCK, OUTPUT);
  pinMode(DATA, OUTPUT);

  for(int i = 0; i &lt; 10; ++i){
    digitalWrite(DATA, LOW);
    digitalWrite(CLOCK, HIGH);
    digitalWrite(CLOCK, LOW);
  }
}

void loop() {
  for(int i = 0; i &lt; 10; ++i){
    int hilo = random(0, 2);

    switch(hilo){
        case 0: digitalWrite(DATA, LOW); break;
        case 1: digitalWrite(DATA, HIGH); break;
    }

    digitalWrite(CLOCK, HIGH);
    digitalWrite(CLOCK, LOW);
    delay(50);
  }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.bendauphinee.com/2012/02/shift-the-graph/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Heatmap Gradient Color Generator</title>
		<link>http://blog.bendauphinee.com/2011/12/php-heatmap-gradient-color-generator/</link>
		<comments>http://blog.bendauphinee.com/2011/12/php-heatmap-gradient-color-generator/#comments</comments>
		<pubDate>Mon, 26 Dec 2011 02:57:57 +0000</pubDate>
		<dc:creator>Ben Dauphinee</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[colors]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[gradient]]></category>
		<category><![CDATA[heatmap]]></category>
		<category><![CDATA[hex]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.bendauphinee.com/?p=137</guid>
		<description><![CDATA[Based on the awesome work done here Samson PHP Color Gradient Generator, I have packed up his code into two functions that are by default set to generate heatmap blue to red color gradients, in as many steps as you need.]]></description>
			<content:encoded><![CDATA[<p>Based on the awesome work done here <a href="http://www.herethere.net/~samson/php/color_gradient/" title="Samson PHP Color Gradient Generator" target="_blank">Samson PHP Color Gradient Generator</a>, I have packed up his code into two functions that are by default set to generate heatmap blue to red color gradients, in as many steps as you need.</p>
<pre class="brush: php; title: ; notranslate">function heatSteps($config){
    $config['colorStart'] = (isset($config['colorStart'])) ? hexdec($config['colorStart']) : 0xdee7f8;
    $config['colorEnd'] = (isset($config['colorEnd'])) ? hexdec($config['colorEnd']) : 0xff0f15;
    $config['colorSteps'] = (isset($config['colorSteps'])) ? $config['colorSteps'] : 10;

    $config['colorStart'] = (($config['colorStart'] &gt;= 0x000000) &amp;&amp; ($config['colorStart'] &lt;= 0xffffff)) ? $config['colorStart'] : 0x000000;
    $config['colorEnd'] = (($config['colorEnd'] &gt;= 0x000000) &amp;&amp; ($config['colorEnd'] &lt;= 0xffffff)) ? $config['colorEnd'] : 0xffffff;
    $config['colorSteps'] = (($config['colorSteps'] &gt; 0) &amp;&amp; ($config['colorSteps'] &lt; 256)) ? $config['colorSteps'] : 256;

    $theR0 = ($config['colorStart'] &amp; 0xff0000) &gt;&gt; 16;
    $theG0 = ($config['colorStart'] &amp; 0x00ff00) &gt;&gt; 8;
    $theB0 = ($config['colorStart'] &amp; 0x0000ff) &gt;&gt; 0;

    $theR1 = ($config['colorEnd'] &amp; 0xff0000) &gt;&gt; 16;
    $theG1 = ($config['colorEnd'] &amp; 0x00ff00) &gt;&gt; 8;
    $theB1 = ($config['colorEnd'] &amp; 0x0000ff) &gt;&gt; 0;

    $colorSteps = array();
    for($i = 0; $i &lt;= $config['colorSteps']; $i++){
        $theR = interpolateHeatSteps($theR0, $theR1, $i, $config['colorSteps']);
        $theG = interpolateHeatSteps($theG0, $theG1, $i, $config['colorSteps']);
        $theB = interpolateHeatSteps($theB0, $theB1, $i, $config['colorSteps']);

        $colorSteps[] = dechex(((($theR &lt;&lt; 8) | $theG) &lt;&lt; 8) | $theB);
    }

    return($colorSteps);
}

function interpolateHeatSteps($pBegin, $pEnd, $pStep, $pMax){
    if ($pBegin &lt; $pEnd){
        return(($pEnd - $pBegin) * ($pStep / $pMax)) + $pBegin;
    }else{
        return(($pBegin - $pEnd) * (1 - ($pStep / $pMax))) + $pEnd;
    }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.bendauphinee.com/2011/12/php-heatmap-gradient-color-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Reddit pi Icon and :hover</title>
		<link>http://blog.bendauphinee.com/2011/10/the-reddit-pi-icon-and-hover/</link>
		<comments>http://blog.bendauphinee.com/2011/10/the-reddit-pi-icon-and-hover/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 00:26:15 +0000</pubDate>
		<dc:creator>Ben Dauphinee</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[pi]]></category>
		<category><![CDATA[reddit]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://blog.bendauphinee.com/?p=130</guid>
		<description><![CDATA[Today I had a task come up on my list that I&#8217;ve been interested in digging into for a while. After seeing the reddit &#960; icon, and learning that it&#8217;s awesome, as well as reference to the movie The Net, I wanted to make use of the idea to hold some info on page generation [...]]]></description>
			<content:encoded><![CDATA[<p>Today I had a task come up on my list that I&#8217;ve been interested in digging into for a while. After seeing the <a href="http://www.reddit.com/" title="reddit" target="_reddit">reddit</a> <span style="font: 16pt serif;">&pi;</span> icon, and learning that it&#8217;s awesome, as well as reference to the movie <a href="http://en.wikipedia.org/wiki/The_Net_(1995_film)" title="The Net" target="_thenet">The Net</a>, I wanted to make use of the idea to hold some info on page generation times and a few other things useful as a dev on a site I&#8217;m working on.</p>
<p>So, digging in with Chrome&#8217;s developer tools, I looked into figuring out how to do it. At first, I thought it was a Javascript thing, using jQuery and mouseOver events, because that&#8217;s how it could have been done. However, that seemed a little heavy for this purpose, since it&#8217;d require some Javascript be loaded on each load. So, examining it a bit closer, I dug into the CSS, and discovered a new use of the pseudo property :hover.</p>
<p>Today I learned that you can use :hover on a parent element to change properties on a child element. Of course, it makes perfect sense now to use it like that, but it was one of those Ooohhhh! moments that you get when something obvious smacks you in the face.</p>
<p>Here&#8217;s one way to do the reddit <span style="font: 16pt serif;">&pi;</span> icon:</p>
<pre class="brush: plain; title: ; notranslate">
&lt;style type=&quot;text/css&quot;&gt;
#pibottom{float: right; padding-top: 4px;}
#pi{color: #a0a0a0; font: 16pt serif; padding: 2px;}
#picontent{font-size: 11pt; display: none;}
#pibottom:hover #picontent{display:inline;}
&lt;/style&gt;

&lt;br clear=&quot;all&quot;&gt;
&lt;div id=&quot;pibottom&quot;&gt;
    &lt;span id=&quot;pi&quot;&gt;&amp;pi;&lt;/span&gt;&amp;nbsp;&lt;span id=&quot;picontent&quot;&gt;Load in ' . getScriptTiming() . ' sec. Ran ' . getCountDBQueries() . ' queries.&lt;/span&gt;
&lt;/div&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.bendauphinee.com/2011/10/the-reddit-pi-icon-and-hover/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

