<?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>deleteaso &#187; arduino</title>
	<atom:link href="http://deleteaso.com/category/arduino/feed/" rel="self" type="application/rss+xml" />
	<link>http://deleteaso.com</link>
	<description>When something's not working delete aso files</description>
	<lastBuildDate>Tue, 25 Oct 2011 13:32:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>2 Sparkfun’s 7-Segment Red 6.5? Display and Arduino</title>
		<link>http://deleteaso.com/2-sparkfun%e2%80%99s-7-segment-red-65%e2%80%b3-display-and-arduino/</link>
		<comments>http://deleteaso.com/2-sparkfun%e2%80%99s-7-segment-red-65%e2%80%b3-display-and-arduino/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 02:12:57 +0000</pubDate>
		<dc:creator>julian</dc:creator>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[arudino]]></category>
		<category><![CDATA[sparkfun]]></category>

		<guid isPermaLink="false">http://deleteaso.com/?p=175</guid>
		<description><![CDATA[A few weeks ago I posted about connecting Sparkfun&#8217;s 7-Segment 6.5&#8243; Display&#8217;s to Arduino. In that post I only showed how to hook up 1 digit. In this post I will show how to hook up 2, but it scales to however many you want to add. Much of the same applies from my previous [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago I posted about connecting <a href="http://deleteaso.com/sparkfuns-7-segment-red-65-display-and-arduino/" target="_blank">Sparkfun&#8217;s 7-Segment 6.5&#8243; Display&#8217;s to Arduino</a>. In that post I only showed how to hook up 1 digit. In this post I will show how to hook up 2, but it scales to however many you want to add. Much of the same applies from my previous post but here are new diagrams and code.</p>
<p><a href="http://www.flickr.com/photos/tfan/3642873986/"><img class="alignnone" title="2 Sparkfun digits hooked up to Arduino" src="http://farm4.static.flickr.com/3635/3642873986_96d457dcd2.jpg?v=0" alt="" width="500" height="329" /></a></p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">&nbsp;
<span style="color: #993333;">int</span> dataPin <span style="color: #339933;">=</span> <span style="color: #0000dd;">11</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> clockPin <span style="color: #339933;">=</span> <span style="color: #0000dd;">12</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> latchPin <span style="color: #339933;">=</span> <span style="color: #0000dd;">8</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">int</span> len <span style="color: #339933;">=</span> <span style="color: #0000dd;">10</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//holders for infromation you're going to pass to shifting function</span>
byte dataRED<span style="color: #339933;">;</span>
byte dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">10</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
byte off <span style="color: #339933;">=</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">;</span>
byte decimalpoint <span style="color: #339933;">=</span> <span style="color: #208080;">0x80</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #993333;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//set pins to output because they are addressed in the main loop</span>
  pinMode<span style="color: #009900;">&#40;</span>latchPin<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//Arduino doesn't seem to have a way to write binary straight into the code</span>
  <span style="color: #666666; font-style: italic;">//so these values are in HEX.  Decimal would have been fine, too.</span>
&nbsp;
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x3F</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//00111111 - 0</span>
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x06</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//00000110 - 1</span>
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x5B</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//01011011 - 2</span>
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x4F</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//01001111 - 3</span>
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">4</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x66</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//01100110 - 4</span>
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">5</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x6D</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//01101101 - 5</span>
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">6</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x7D</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//01111101 - 6</span>
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">7</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x07</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//00000111 - 7</span>
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">8</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x7F</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//01111111 - 8</span>
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">9</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x67</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//01100111 - 9</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #993333;">int</span> count <span style="color: #339933;">=</span> <span style="color: #0000dd;">100</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> val <span style="color: #339933;">=</span> <span style="color: #0000dd;">10</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//this is for how many digits</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #993333;">int</span> i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>count<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>latchPin<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
   <span style="color: #993333;">int</span> digit2 <span style="color: #339933;">=</span> i <span style="color: #339933;">%</span> val<span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> digit1 <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> i <span style="color: #339933;">-</span> digit2 <span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> val<span style="color: #339933;">;</span>
&nbsp;
    shiftOut<span style="color: #009900;">&#40;</span>dataPin<span style="color: #339933;">,</span> clockPin<span style="color: #339933;">,</span> dataArrayRED<span style="color: #009900;">&#91;</span> digit2 <span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    shiftOut<span style="color: #009900;">&#40;</span>dataPin<span style="color: #339933;">,</span> clockPin<span style="color: #339933;">,</span> dataArrayRED<span style="color: #009900;">&#91;</span> digit1 <span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  digitalWrite<span style="color: #009900;">&#40;</span>latchPin<span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">300</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">// the heart of the program</span>
<span style="color: #993333;">void</span> shiftOut<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> myDataPin<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> myClockPin<span style="color: #339933;">,</span> byte myDataOut<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// This shifts 8 bits out MSB first,</span>
  <span style="color: #666666; font-style: italic;">//on the rising edge of the clock,</span>
  <span style="color: #666666; font-style: italic;">//clock idles low</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//internal function setup</span>
  <span style="color: #993333;">int</span> i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> pinState<span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>myClockPin<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>myDataPin<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//clear everything out just in case to</span>
  <span style="color: #666666; font-style: italic;">//prepare shift register for bit shifting</span>
  digitalWrite<span style="color: #009900;">&#40;</span>myDataPin<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>myClockPin<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//for each bit in the byte myDataOut…</span>
  <span style="color: #666666; font-style: italic;">//NOTICE THAT WE ARE COUNTING DOWN in our for loop</span>
  <span style="color: #666666; font-style: italic;">//This means that %00000001 or &quot;1&quot; will go through such</span>
  <span style="color: #666666; font-style: italic;">//that it will be pin Q0 that lights.</span>
&nbsp;
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #0000dd;">7</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&gt;=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span>  
  <span style="color: #009900;">&#123;</span>
    digitalWrite<span style="color: #009900;">&#40;</span>myClockPin<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//if the value passed to myDataOut and a bitmask result</span>
    <span style="color: #666666; font-style: italic;">// true then... so if we are at i=6 and our value is</span>
    <span style="color: #666666; font-style: italic;">// %11010100 it would the code compares it to %01000000</span>
    <span style="color: #666666; font-style: italic;">// and proceeds to set pinState to 1.</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> myDataOut <span style="color: #339933;">&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #339933;">&lt;&lt;</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> 
    <span style="color: #009900;">&#123;</span>
	pinState<span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">else</span> 
    <span style="color: #009900;">&#123;</span>
	pinState<span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//Sets the pin to HIGH or LOW depending on pinState</span>
&nbsp;
    digitalWrite<span style="color: #009900;">&#40;</span>myDataPin<span style="color: #339933;">,</span> pinState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//register shifts bits on upstroke of clock pin</span>
    digitalWrite<span style="color: #009900;">&#40;</span>myClockPin<span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//zero the data pin after shift to prevent bleed through</span>
    digitalWrite<span style="color: #009900;">&#40;</span>myDataPin<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//stop shifting</span>
  digitalWrite<span style="color: #009900;">&#40;</span>myClockPin<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I also have a video uploaded on <a href="http://www.viddler.com/explore/julian/videos/16/" target="_blank">viddler</a></p>
<p>Now that I have this up and running I just have to do something useful with it. And I have to find a better way to solder the digits, because there are wires everywhere.</p>
]]></content:encoded>
			<wfw:commentRss>http://deleteaso.com/2-sparkfun%e2%80%99s-7-segment-red-65%e2%80%b3-display-and-arduino/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Sparkfun&#8217;s 7-Segment Red 6.5&#8243; Display and Arduino</title>
		<link>http://deleteaso.com/sparkfuns-7-segment-red-65-display-and-arduino/</link>
		<comments>http://deleteaso.com/sparkfuns-7-segment-red-65-display-and-arduino/#comments</comments>
		<pubDate>Sat, 30 May 2009 20:37:13 +0000</pubDate>
		<dc:creator>julian</dc:creator>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[publications]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://deleteaso.com/?p=164</guid>
		<description><![CDATA[A little while ago I purchased 10 of Sparkfun&#8217;s 7-segment red 6.5&#8243; displays. http://www.sparkfun.com/commerce/product_info.php?products_id=8530 I had been wanting to purchase them for quite some time but they had been out of stock. When I was finally notified that they had received more I instantly bought them, without really thinking what I was going to use [...]]]></description>
			<content:encoded><![CDATA[<p>A little while ago I purchased 10 of Sparkfun&#8217;s 7-segment red 6.5&#8243; displays.</p>
<p><a href="http://www.sparkfun.com/commerce/product_info.php?products_id=8530" target="_blank">http://www.sparkfun.com/commerce/product_info.php?products_id=8530</a></p>
<p>I had been wanting to purchase them for quite some time but they had been out of stock. When I was finally notified that they had received more I instantly bought them, without really thinking what I was going to use them for. Once they arrived I quickly opened them up and saw that it was going to be a little bit more of a challenge then I originally thought it would be. And I also thought they would come with some fancy schematic that I could just follow, but they didn&#8217;t.</p>
<p>So the first step was just to try and get a segment to light up by just supplying power. The digits use a common anode, which means it has one lead connection and 7 ground connection for each segment. So I started running it through a 5v power supply with not luck. Then a 9v, still no luck. Finally 12v did the trick. After I soldered wires to all of the connection I was able to get all 7 segments to light up by just running the common anode to the power and each segment to a ground.</p>
<p><a href="http://www.flickr.com/photos/tfan/3579607606/?rotated=1&amp;cb=1243714573465"><img class="alignnone" title="Segement Displays" src="http://farm4.static.flickr.com/3348/3579607606_e66b7bb94c.jpg?v=1243714572" alt="" width="500" height="375" /></a></p>
<p>Ok so step one complete now to try and get it talking with Arduino. Now I wasn&#8217;t really sure how to go about doing this since each segment was connected to a ground. So I started digging around on the Arduino forums and found some similar posts on what I was trying to do. My conclusion was that I need to get a shift register to turn each segment on and off. I found some people who had some luck with this display and the <a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&amp;name=620-1165-5-ND" target="_blank">Allegro 6278EAT</a>. You can pick some up for $1.55 at Digi Key. There are lots of different LED drivers out there but the reason I chose this one was because I needed to supply 12v to my displays and it sounded like some of the others that people where recommending wouldn&#8217;t work.</p>
<p>So after a lot of experimenting and researching I was finally able to get the display to turn on and off with Arduino. This <a href="http://arduino.cc/en/Tutorial/ShiftOut" target="_blank">tutorial</a> on the Arduino site was the most helpful. And I used the following Arduino sketch which I got from this <a href="http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1212882269;start=all" target="_blank">post</a> on the forums.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">int</span> dataPin <span style="color: #339933;">=</span> <span style="color: #0000dd;">11</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> clockPin <span style="color: #339933;">=</span> <span style="color: #0000dd;">12</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> latchPin <span style="color: #339933;">=</span> <span style="color: #0000dd;">10</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//holders for infromation you're going to pass to shifting function</span>
byte dataRED<span style="color: #339933;">;</span>
&nbsp;
byte dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">11</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//set pins to output because they are addressed in the main loop</span>
  pinMode<span style="color: #009900;">&#40;</span>latchPin<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//Arduino doesn't seem to have a way to write binary straight into the code</span>
  <span style="color: #666666; font-style: italic;">//so these values are in HEX.  Decimal would have been fine, too.</span>
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x3F</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//00111111 - 0</span>
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x06</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//00000110 - 1</span>
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x5B</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//01011011 - 2</span>
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x4F</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//01001111 - 3</span>
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">4</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x66</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//01100110 - 4</span>
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">5</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x6D</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//01101101 - 5</span>
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">6</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x7D</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//01111101 - 6</span>
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">7</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x07</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//00000111 - 7</span>
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">8</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x7F</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//01111111 - 8</span>
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">9</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x67</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//01100111 - 9</span>
  dataArrayRED<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">10</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x80</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//decimal point</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span><span style="color: #0000dd;">11</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
&nbsp;
  dataRED <span style="color: #339933;">=</span> dataArrayRED<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//ground latchPin and hold low for as long as you are transmitting</span>
&nbsp;
    digitalWrite<span style="color: #009900;">&#40;</span>latchPin<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//move 'em out</span>
&nbsp;
    shiftOut<span style="color: #009900;">&#40;</span>dataPin<span style="color: #339933;">,</span> clockPin<span style="color: #339933;">,</span> dataRED<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//return the latch pin high to signal chip that it</span>
    <span style="color: #666666; font-style: italic;">//no longer needs to listen for information</span>
    digitalWrite<span style="color: #009900;">&#40;</span>latchPin<span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">300</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// the heart of the program</span>
<span style="color: #993333;">void</span> shiftOut<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> myDataPin<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> myClockPin<span style="color: #339933;">,</span> byte myDataOut<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// This shifts 8 bits out MSB first,</span>
  <span style="color: #666666; font-style: italic;">//on the rising edge of the clock,</span>
  <span style="color: #666666; font-style: italic;">//clock idles low</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//internal function setup</span>
  <span style="color: #993333;">int</span> i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> pinState<span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>myClockPin<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>myDataPin<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//clear everything out just in case to</span>
  <span style="color: #666666; font-style: italic;">//prepare shift register for bit shifting</span>
  digitalWrite<span style="color: #009900;">&#40;</span>myDataPin<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>myClockPin<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//for each bit in the byte myDataOut…</span>
  <span style="color: #666666; font-style: italic;">//NOTICE THAT WE ARE COUNTING DOWN in our for loop</span>
  <span style="color: #666666; font-style: italic;">//This means that %00000001 or &quot;1&quot; will go through such</span>
  <span style="color: #666666; font-style: italic;">//that it will be pin Q0 that lights.</span>
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #0000dd;">7</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    digitalWrite<span style="color: #009900;">&#40;</span>myClockPin<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//if the value passed to myDataOut and a bitmask result</span>
    <span style="color: #666666; font-style: italic;">// true then... so if we are at i=6 and our value is</span>
    <span style="color: #666666; font-style: italic;">// %11010100 it would the code compares it to %01000000</span>
    <span style="color: #666666; font-style: italic;">// and proceeds to set pinState to 1.</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> myDataOut <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#123;</span>
	pinState<span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">else</span>
    <span style="color: #009900;">&#123;</span>
	pinState<span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//Sets the pin to HIGH or LOW depending on pinState</span>
    digitalWrite<span style="color: #009900;">&#40;</span>myDataPin<span style="color: #339933;">,</span> pinState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//register shifts bits on upstroke of clock pin</span>
    digitalWrite<span style="color: #009900;">&#40;</span>myClockPin<span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//zero the data pin after shift to prevent bleed through</span>
    digitalWrite<span style="color: #009900;">&#40;</span>myDataPin<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//stop shifting</span>
  digitalWrite<span style="color: #009900;">&#40;</span>myClockPin<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And here is a final diagram for connecting it to Arduino.</p>
<p><a href="http://www.flickr.com/photos/tfan/3579173968/"><img class="alignnone" title="1 segment diagram" src="http://farm4.static.flickr.com/3315/3579173968_2fc55360eb.jpg?v=0" alt="" width="500" height="287" /></a></p>
<p>NOTE: the diagram shows a 15kohm resistor but it may not be bright enough. If you put a 2.2kohm resistor it will be much brighter</p>
<p>And here is a video of the display counting &#8211; <a href="http://www.viddler.com/explore/julian/videos/14/" target="_blank">http://www.viddler.com/explore/julian/videos/14/</a></p>
<p>I am working on getting more then one display working and will write a new post when I do</p>
]]></content:encoded>
			<wfw:commentRss>http://deleteaso.com/sparkfuns-7-segment-red-65-display-and-arduino/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

