Differences

This shows you the differences between two versions of the page.

Link to this comparison view

products:ardx:circ-05 [2012/09/07 01:12] (current)
Line 1: Line 1:
  
 +<html>
 +<div id="CIRC-head">
 +<div id="CIRC-100"><table height="100px" width="100px" valign="center"><tr><td><span class="headText"><center>CIRC<br>05</center></span></td></tr></table></div>
 +<div id="CIRC-465"><table height="100px" width="465px" valign="center"><tr><td><span class="subText"><center>.:8 More LEDs:.<br>.:74HC595 Shift Register:.</center></span></td></tr></table></div>
 +<div id="CIRC-100"><img src="http://www.ardx.org/src/circ/CIRC-05-square-100.jpg" width="100" height="100"></div>
 +</div>
 +<span class="familyName"><center>(ARDX)   .:Arduino Expermentation Kit:.   (ARDX)</center></span>
 +<div id="CIRC-whitespace"></div>
 +<div id="CIRC-body">
 +<div id="CIRC-whitespace"></div><br>
 +<div id="CIRC-whatweredoing">
 +<span class="titleText">What We're Doing</span><br>
 +<span class="regularText">Time to start playing with chips, or integrated circuits (ICs) as they like to be called. The external packaging of a chip can be very deceptive. For example, the chip on the Arduino board (a microcontroller) and the one we will use in this circuit (a shift register) look very similar but are in fact rather different. The price of the ATMega chip on the Arduino board is a few dollars while the 74HC595 is a couple dozen cents. It's a good introductory chip, and once you're comfortable playing around with it and its datasheet (available online <a href="http://ardx.org/74HC595 ">http://ardx.org/74HC595 </a>) the world of chips will be your oyster. The shift register (also called a serial to parallel converter), will give you an additional 8 outputs (to control LEDs and the like) using only three Arduino pins. They can also be linked together to give you a nearly unlimited number of outputs using the same four pins. To use it you "clock in" the data and then lock it in (latch it). To do this you set the data pin to either HIGH or LOW, pulse the clock, then set the data pin again and pulse the clock repeating until you have shifted out 8 bits of data. Then you pulse the latch and the 8 bits are transferred to the shift registers pins. It sounds complicated but is really simple once you get the hang of it. <br>(for a more in depth look at how a shift register works visit: <a href="http://ardx.org/SHIF ">http://ardx.org/SHIF </a>)</span>
 +</div><br>
 +<div id="CIRC-whitespace"></div><br>
 +<div id="CIRC-thecircuit">
 +<span class="titleText">The Circuit</span><br>
 +<div id="CIRC-thepartsSideSpacer">
 +</div>
 +        <div id="CIRC-theparts">
 +          <span class="smallTitleText">The Parts</span><br>
 +          <span class="regularText">
 +<table>
 +<tr>
 +<td>
 +<img src="http://www.oomlout.com/parts/CIRC-01-3dsheet-60.png" width="60px" height="36px">
 +</td>
 +<td>
 +<span class="partsText">
 +CIRC-05<br>Breadboard Sheet<br>x1
 +</span>
 +</td>
 +<td>
 +<img src="http://www.oomlout.com/parts/HEAD-02-60.png" width="60px" height="36px">
 +</td>
 +<td>
 +<span class="partsText">
 +2 Pin Header<br>x4
 +</span>
 +</td>
 +<td>
 +<img src="http://www.oomlout.com/parts/IC-74HC595-60.png" width="60px" height="36px">
 +</td>
 +<td>
 +<span class="partsText">
 +Shift Register<br>74HC595<br>x1
 +</span>
 +</td>
 +<td>
 +
 +<img src="http://www.oomlout.com/parts/WIRE-01-60.png" width="60px" height="36px">
 +</td>
 +<td>
 +<span class="partsText">
 +Wire
 +</span>
 +</td>
 +</tr>
 +
 +<tr>
 +<td>
 +<img src="http://www.oomlout.com/parts/LED-05R-60.png" width="60px" height="36px">
 +</td>
 +<td>
 +<span class="partsText">
 +Red LED<br>x8
 +</span>
 +</td>
 +<td>
 +<img src="http://www.oomlout.com/parts/RES-561-60.png" width="60px" height="36px">
 +</td>
 +<td>
 +<span class="partsText">
 +560 Ohm Resistor<br>Green-Blue-Brown <br>x8
 +</span>
 +</td>
 +<td>
 +<img src="http://www.oomlout.com/parts/BLANK.png" width="60px" height="36px">
 +</td>
 +<td>
 +<span class="partsText">
 +
 +</span>
 +</td>
 +<td>
 +
 +<img src="http://www.oomlout.com/parts/BLANK.png" width="60px" height="36px">
 +</td>
 +<td>
 +<span class="partsText">
 +
 +</span>
 +</td>
 +</tr>
 +</table>
 +</span>
 +        </div><br>
 +        <div id="CIRC-whitespace"></div><br>
 +        <div id="CIRC-thepartsSideSpacer"></div>
 +          <div id="CIRC-circuitBox">
 +            <div id="CIRC-schematic"><center><span class="smallTitleText">Schematic</span><span class="smallTitleText"><img src="http://www.ardx.org/src/circ/ARDX-SC-05-150.png"></span></center></div>
 + <br>
 + <div id="CIRC-smallwhitespace">&nbsp;</div><br>
 +            <div id="CIRC-resources">
 + <center><span class="smallTitleText">Resources</span><br><span class="smallMediumDarkText"><b>.:download:.</b><br>breadboard layout sheet<br><b><a href="http://ardx.org/BBLS05">http://ardx.org/BBLS05</a></b><br><br><b>.:view:.</b><br>assembly video <b><br><a href="http://ardx.org/VIDE05">http://ardx.org/VIDE05</a></b></span></center>
 +            </div>
 +          </div>
 +        <div id="CIRC-circuitPicture">
 +          <center>
 +            <img src="http://www.ardx.org/src/circ/CIRC05-3dexploded-445.png" width="445">
 +          </center>
 +        </div>
 +      </div><br>
 +      <div id="CIRC-whitespace">&nbsp;</div><br>
 +<div id="CIRC-thecode">
 +        <span class="titleText">Code</span> <span class="smallDarkText">(no need to type everything in just)</span><br>
 +        <span class="mediumDarkText">Download the Code from ( <a href="http://ardx.org/CODE05 ">http://ardx.org/CODE05 </a>)<br>(copy the text and paste it into an empty Arduino Sketch) </span><br>
 +        <span class="code">        <prew>/*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;<br>
 +&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;Arduino&nbsp;Experimentation&nbsp;Kit&nbsp;Example&nbsp;Code&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|<br>
 +&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;CIRC&#45;05&nbsp;.:&nbsp;8&nbsp;More&nbsp;LEDs&nbsp;:.&nbsp;(74HC595&nbsp;Shift&nbsp;Register)&nbsp;&nbsp;&nbsp;|<br>
 +&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;<br>
 +&nbsp;*&nbsp;<br>
 +&nbsp;*&nbsp;We&nbsp;have&nbsp;already&nbsp;controlled&nbsp;8&nbsp;LEDs&nbsp;however&nbsp;this&nbsp;does&nbsp;it&nbsp;in&nbsp;a&nbsp;slightly<br>
 +&nbsp;*&nbsp;different&nbsp;manner.&nbsp;Rather&nbsp;than&nbsp;using&nbsp;8&nbsp;pins&nbsp;we&nbsp;will&nbsp;use&nbsp;just&nbsp;three<br>
 +&nbsp;*&nbsp;and&nbsp;an&nbsp;additional&nbsp;chip.<br>
 +&nbsp;*<br>
 +&nbsp;*<br>
 +&nbsp;*/<br>
 +<br>
 +<br>
 +//Pin&nbsp;Definitions<br>
 +//Pin&nbsp;Definitions<br>
 +//The&nbsp;74HC595&nbsp;uses&nbsp;a&nbsp;serial&nbsp;communication&nbsp;<br>
 +//link&nbsp;which&nbsp;has&nbsp;three&nbsp;pins<br>
 +int&nbsp;data&nbsp;=&nbsp;2;&nbsp;<br>
 +int&nbsp;clock&nbsp;=&nbsp;3;<br>
 +int&nbsp;latch&nbsp;=&nbsp;4;<br>
 +<br>
 +//Used&nbsp;for&nbsp;single&nbsp;LED&nbsp;manipulation<br>
 +int&nbsp;ledState&nbsp;=&nbsp;0;<br>
 +const&nbsp;int&nbsp;ON&nbsp;=&nbsp;HIGH;<br>
 +const&nbsp;int&nbsp;OFF&nbsp;=&nbsp;LOW;<br>
 +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
 +<br>
 +/*<br>
 +&nbsp;*&nbsp;setup()&nbsp;&#45;&nbsp;this&nbsp;function&nbsp;runs&nbsp;once&nbsp;when&nbsp;you&nbsp;turn&nbsp;your&nbsp;Arduino&nbsp;on<br>
 +&nbsp;*&nbsp;We&nbsp;set&nbsp;the&nbsp;three&nbsp;control&nbsp;pins&nbsp;to&nbsp;outputs<br>
 +&nbsp;*/<br>
 +void&nbsp;setup()<br>
 +{<br>
 +&nbsp;&nbsp;pinMode(data,&nbsp;OUTPUT);<br>
 +&nbsp;&nbsp;pinMode(clock,&nbsp;OUTPUT);&nbsp;&nbsp;<br>
 +&nbsp;&nbsp;pinMode(latch,&nbsp;OUTPUT);&nbsp;&nbsp;<br>
 +}<br>
 +<br>
 +/*<br>
 +&nbsp;*&nbsp;loop()&nbsp;&#45;&nbsp;this&nbsp;function&nbsp;will&nbsp;start&nbsp;after&nbsp;setup&nbsp;finishes&nbsp;and&nbsp;then&nbsp;repeat<br>
 +&nbsp;*&nbsp;we&nbsp;set&nbsp;which&nbsp;LEDs&nbsp;we&nbsp;want&nbsp;on&nbsp;then&nbsp;call&nbsp;a&nbsp;routine&nbsp;which&nbsp;sends&nbsp;the&nbsp;states&nbsp;to&nbsp;the&nbsp;74HC595<br>
 +&nbsp;*/<br>
 +void&nbsp;loop()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;run&nbsp;over&nbsp;and&nbsp;over&nbsp;again<br>
 +{<br>
 +&nbsp;&nbsp;int&nbsp;delayTime&nbsp;=&nbsp;100;&nbsp;//the&nbsp;number&nbsp;of&nbsp;milliseconds&nbsp;to&nbsp;delay&nbsp;between&nbsp;LED&nbsp;updates<br>
 +&nbsp;&nbsp;for(int&nbsp;i&nbsp;=&nbsp;0;&nbsp;i&nbsp;<&nbsp;256;&nbsp;i++){<br>
 +&nbsp;&nbsp;&nbsp;updateLEDs(i);<br>
 +&nbsp;&nbsp;&nbsp;delay(delayTime);&nbsp;<br>
 +&nbsp;&nbsp;}<br>
 +}<br>
 +<br>
 +<br>
 +<br>
 +/*<br>
 +&nbsp;*&nbsp;updateLEDs()&nbsp;&#45;&nbsp;sends&nbsp;the&nbsp;LED&nbsp;states&nbsp;set&nbsp;in&nbsp;ledStates&nbsp;to&nbsp;the&nbsp;74HC595<br>
 +&nbsp;*&nbsp;sequence<br>
 +&nbsp;*/<br>
 +void&nbsp;updateLEDs(int&nbsp;value){<br>
 +&nbsp;&nbsp;digitalWrite(latch,&nbsp;LOW);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//Pulls&nbsp;the&nbsp;chips&nbsp;latch&nbsp;low<br>
 +&nbsp;&nbsp;shiftOut(data,&nbsp;clock,&nbsp;MSBFIRST,&nbsp;value);&nbsp;//Shifts&nbsp;out&nbsp;the&nbsp;8&nbsp;bits&nbsp;to&nbsp;the&nbsp;shift&nbsp;register<br>
 +&nbsp;&nbsp;digitalWrite(latch,&nbsp;HIGH);&nbsp;&nbsp;&nbsp;//Pulls&nbsp;the&nbsp;latch&nbsp;high&nbsp;displaying&nbsp;the&nbsp;data<br>
 +}<br>
 +<br>
 +/*<br>
 +&nbsp;*&nbsp;updateLEDsLong()&nbsp;&#45;&nbsp;sends&nbsp;the&nbsp;LED&nbsp;states&nbsp;set&nbsp;in&nbsp;ledStates&nbsp;to&nbsp;the&nbsp;74HC595<br>
 +&nbsp;*&nbsp;sequence.&nbsp;Same&nbsp;as&nbsp;updateLEDs&nbsp;except&nbsp;the&nbsp;shifting&nbsp;out&nbsp;is&nbsp;done&nbsp;in&nbsp;software<br>
 +&nbsp;*&nbsp;so&nbsp;you&nbsp;can&nbsp;see&nbsp;what&nbsp;is&nbsp;happening.<br>
 +&nbsp;*/&nbsp;<br>
 +void&nbsp;updateLEDsLong(int&nbsp;value){<br>
 +&nbsp;&nbsp;digitalWrite(latch,&nbsp;LOW);&nbsp;&nbsp;&nbsp;&nbsp;//Pulls&nbsp;the&nbsp;chips&nbsp;latch&nbsp;low<br>
 +&nbsp;&nbsp;for(int&nbsp;i&nbsp;=&nbsp;0;&nbsp;i&nbsp;<&nbsp;8;&nbsp;i++){&nbsp;&nbsp;//Will&nbsp;repeat&nbsp;8&nbsp;times&nbsp;(once&nbsp;for&nbsp;each&nbsp;bit)<br>
 +&nbsp;&nbsp;int&nbsp;bit&nbsp;=&nbsp;value&nbsp;&&nbsp;B10000000;&nbsp;//We&nbsp;use&nbsp;a&nbsp;"bitmask"&nbsp;to&nbsp;select&nbsp;only&nbsp;the&nbsp;eighth&nbsp;<br>
 +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//bit&nbsp;in&nbsp;our&nbsp;number&nbsp;(the&nbsp;one&nbsp;we&nbsp;are&nbsp;addressing&nbsp;this&nbsp;time&nbsp;thro<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//ugh<br>
 +&nbsp;&nbsp;value&nbsp;=&nbsp;value&nbsp;<<&nbsp;1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//we&nbsp;move&nbsp;our&nbsp;number&nbsp;up&nbsp;one&nbsp;bit&nbsp;value&nbsp;so&nbsp;next&nbsp;time&nbsp;bit&nbsp;7&nbsp;will<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;be<br>
 +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//bit&nbsp;8&nbsp;and&nbsp;we&nbsp;will&nbsp;do&nbsp;our&nbsp;math&nbsp;on&nbsp;it<br>
 +&nbsp;&nbsp;if(bit&nbsp;==&nbsp;128){digitalWrite(data,&nbsp;HIGH);}&nbsp;//if&nbsp;bit&nbsp;8&nbsp;is&nbsp;set&nbsp;then&nbsp;set&nbsp;our&nbsp;data&nbsp;pin&nbsp;high<br>
 +&nbsp;&nbsp;else{digitalWrite(data,&nbsp;LOW);}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//if&nbsp;bit&nbsp;8&nbsp;is&nbsp;unset&nbsp;then&nbsp;set&nbsp;the&nbsp;data&nbsp;pin&nbsp;low<br>
 +&nbsp;&nbsp;digitalWrite(clock,&nbsp;HIGH);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//the&nbsp;next&nbsp;three&nbsp;lines&nbsp;pulse&nbsp;the&nbsp;clock&nbsp;pin<br>
 +&nbsp;&nbsp;delay(1);<br>
 +&nbsp;&nbsp;digitalWrite(clock,&nbsp;LOW);<br>
 +&nbsp;&nbsp;}<br>
 +&nbsp;&nbsp;digitalWrite(latch,&nbsp;HIGH);&nbsp;&nbsp;//pulls&nbsp;the&nbsp;latch&nbsp;high&nbsp;shifting&nbsp;our&nbsp;data&nbsp;into&nbsp;being&nbsp;displayed<br>
 +}<br>
 +<br>
 +<br>
 +//These&nbsp;are&nbsp;used&nbsp;in&nbsp;the&nbsp;bitwise&nbsp;math&nbsp;that&nbsp;we&nbsp;use&nbsp;to&nbsp;change&nbsp;individual&nbsp;LEDs<br>
 +//For&nbsp;more&nbsp;details&nbsp;http://en.wikipedia.org/wiki/Bitwise_operation<br>
 +int&nbsp;bits[]&nbsp;=&nbsp;{B00000001,&nbsp;B00000010,&nbsp;B00000100,&nbsp;B00001000,&nbsp;B00010000,&nbsp;B00100000,&nbsp;B01000000,&nbsp;B10000000};<br>
 +int&nbsp;masks[]&nbsp;=&nbsp;{B11111110,&nbsp;B11111101,&nbsp;B11111011,&nbsp;B11110111,&nbsp;B11101111,&nbsp;B11011111,&nbsp;B10111111,&nbsp;B01111111};<br>
 +/*<br>
 +&nbsp;*&nbsp;changeLED(int&nbsp;led,&nbsp;int&nbsp;state)&nbsp;&#45;&nbsp;changes&nbsp;an&nbsp;individual&nbsp;LED&nbsp;<br>
 +&nbsp;*&nbsp;LEDs&nbsp;are&nbsp;0&nbsp;to&nbsp;7&nbsp;and&nbsp;state&nbsp;is&nbsp;either&nbsp;0&nbsp;&#45;&nbsp;OFF&nbsp;or&nbsp;1&nbsp;&#45;&nbsp;ON<br>
 +&nbsp;*/<br>
 +&nbsp;void&nbsp;changeLED(int&nbsp;led,&nbsp;int&nbsp;state){<br>
 +&nbsp;&nbsp;&nbsp;ledState&nbsp;=&nbsp;ledState&nbsp;&&nbsp;masks[led];&nbsp;&nbsp;//clears&nbsp;ledState&nbsp;of&nbsp;the&nbsp;bit&nbsp;we&nbsp;are&nbsp;addressing<br>
 +&nbsp;&nbsp;&nbsp;if(state&nbsp;==&nbsp;ON){ledState&nbsp;=&nbsp;ledState&nbsp;|&nbsp;bits[led];}&nbsp;//if&nbsp;the&nbsp;bit&nbsp;is&nbsp;on&nbsp;we&nbsp;will&nbsp;add&nbsp;it&nbsp;to&nbsp;le<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//dState<br>
 +&nbsp;&nbsp;&nbsp;updateLEDs(ledState);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//send&nbsp;the&nbsp;new&nbsp;LED&nbsp;state&nbsp;to&nbsp;the&nbsp;shift&nbsp;register<br>
 +&nbsp;}<br>
 +<br>
 +        </prew></span>
 +      </div>
 +      <div id="CIRC-whitespace">&nbsp;</div><br>
 +<div id="CIRC-notWorking">
 +        <span class="titleText">Not Working?</span> <span class="smallDarkText">(3 things to try)</span>
 + <br><div id="CIRC-smallwhitespace">&nbsp;</div><br>
 + <div>
 +        <div id="CIRC-thepartsSideSpacer">&nbsp;</div>
 +        <div id="CIRC-nw1"><center><span class="regularText"><b>The Arduino's power LED goes out </b></span><br><span class="regularText">This happened to us a couple of times, it happens when the chip is inserted backwards. If you fix it quickly nothing will break. </span></center></div>
 +        <div id="CIRC-thepartsSideSpacer">&nbsp;</div>
 +        <div id="CIRC-nw2"><center><span class="regularText"><b>Not Quite Working</b></span><br><span class="regularText"> Sorry to sound like a broken record but it is probably something as simple as  a crossed wire.</span></center></div>
 +        <div id="CIRC-thepartsSideSpacer">&nbsp;</div>
 +        <div id="CIRC-nw3"><center><span class="regularText"><b>Frustration?</b></span><br><span class="regularText">Shoot us an e-mail, this circuit is both simple and complex at the same time. We want to hear about problems you have so we can address them in future editions.<br> help@oomlout.com </span></center></div>
 +        <div id="CIRC-thepartsSideSpacer">&nbsp;</div>
 +</div></div>
 +<div id="CIRC-whitespace">&nbsp;</div><br>
 +<div id="CIRC-makingBetter">
 +<span class="titleText">Making it Better?</span><br>&nbsp;<br>
 +<span class="regularText"><b>Doing it the hard way:</b> <BR>An Arduino makes rather complex actions very easy, shifting out data is one of these cases. However one of the nice features of an Arduino is you can make things as easy or difficult as you like. Lets try an example of this. In your loop switch the line. <BR><span class="bigCode">updateLEDs(i) -> updateLEDsLong(i);</span> <BR>Upload the program and notice nothing has changed. If you look at the code you can see how we are communicating with the chip one bit at a time. (for more details <a href="http://ardx.org/SPI ">http://ardx.org/SPI </a>). <BR>&nbsp; <BR><b>Controlling Individual LEDs:</b> <BR>Time to start controlling the LEDs in a similar method as we did in CIRC02. As the eight LED states are stored in one byte (an 8 bit value) for details on how this works try <a href="http://ardx.org/BINA. ">http://ardx.org/BINA. </a>An Arduino is very good at manipulating bits and there are an entire set of operators that help us out. Details on bitwise maths ( <a href="http://ardx.org/BITW ">http://ardx.org/BITW </a>). <BR>&nbsp; <BR>&nbsp;&nbsp;<b>Our implementation.</b> <BR>&nbsp;&nbsp;&nbsp;&nbsp;Replace the<span class="bigCode">loop()</span> code with <BR>   <span class="bigCode"> <BR>   int delayTime = 100; //the number of milliseconds to delay  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//between LED updates <BR>&nbsp;&nbsp;for(int i = 0; i &lt; 8; i++){ <BR>&nbsp;&nbsp;&nbsp;&nbsp;changeLED(i,ON); <BR>&nbsp;&nbsp;&nbsp;&nbsp;delay(delayTime); <BR>&nbsp;&nbsp;} <BR>&nbsp;&nbsp;for(int i = 0; i &lt; 8; i++){ <BR>&nbsp;&nbsp;&nbsp;&nbsp;changeLED(i,OFF); <BR>&nbsp;&nbsp;&nbsp;&nbsp;delay(delayTime); <BR>&nbsp;&nbsp;} <BR>  </span> <BR>And upload this will cause the lights to light up one after another and then off in a similar manner. Check the code and wikipedia to see how it works, or shoot us an e-mail if you have questions. <BR>&nbsp; <BR><b>More Animations:</b> <BR>Now things get more interesting. If you look back to the code from CIRC02 (8 LED Fun) you see we change the LEDs using <span class="bigCode">digitalWrite(led, state)</span>, this is the same format as the routine we wrote changeLED(led, state). You can use the animations you wrote for CIRC02 by copying the code into this sketch and changing all the <span class="bigCode">digitalWrite()</span>'s to <span class="bigCode">changeLED()</span>'s. Powerful? Very. (you'll also need to change a few other things but follow the compile errors and it works itself out).
 +</span></html>