<?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>DIY DMCole &#187; Digital candle</title>
	<atom:link href="http://www.dmcole.net/index.php/tag/digital-candle/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dmcole.net</link>
	<description>Circuits, microcontrollers, LEDs, do-it-yourself style</description>
	<lastBuildDate>Wed, 09 Jun 2010 23:16:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Digital candle – Version 2</title>
		<link>http://www.dmcole.net/index.php/digital-candle-%e2%80%93-version-2/</link>
		<comments>http://www.dmcole.net/index.php/digital-candle-%e2%80%93-version-2/#comments</comments>
		<pubDate>Thu, 07 May 2009 23:22:29 +0000</pubDate>
		<dc:creator>dmcole</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[ATTiny13]]></category>
		<category><![CDATA[Digital candle]]></category>
		<category><![CDATA[LED]]></category>

		<guid isPermaLink="false">http://www.dmcole.net/?p=95</guid>
		<description><![CDATA[As can be seen from the dates between postings, I took an awful lot of time with this project &#8211; and yet, I never really accomplished my goal, which was to have five LEDs independently fading in and out like a candle, driven by an Atmel ATTiny13.
I spent a lot of time with some code [...]]]></description>
			<content:encoded><![CDATA[<p><strong>As</strong> can be seen from the dates between postings, I took an awful lot of time with this project &ndash; and yet, I never really accomplished my goal, which was to have five LEDs independently fading in and out like a candle, driven by an Atmel ATTiny13.<br />
<div id="attachment_122" class="wp-caption alignright" style="width: 310px"><a href="http://www.dmcole.net/wp-content/uploads/2009/05/digitalcandle-schematic-v2a.pdf" target="_new"><img src="http://www.dmcole.net/wp-content/uploads/2009/05/digitalcandle-schematic-v2a-300x199.jpg" alt="ATTiny13 drives 5 LEDs; programming/test circuit (click to download PDF)" title="digitalcandle-schematic-v2a" width="300" height="199" class="size-medium wp-image-122" border="0" /></a><p class="wp-caption-text">ATTiny13 drives 5 LEDs; programming/test circuit (click to download PDF)</p></div></p>
<p>I spent a lot of time with some code that had been created for a Microchip PIC12F675 but it turned out that it was merely random on-off, not fading the way a flickering candle operates. I then spent some time with a second code set, also for a PIC12F675, that did fade nicely, but which had a problem with brightness that I was never able to rectify (it is a duty-cycle issue, I know; I just don&rsquo;t know how to fix it).</p>
<p>But that <a href="http://www.geocities.com/westfw/electronics/flames.c" target="_new">second code set</a> did point me in the direction of how to control individual LEDs while within a loop, using bitwise manipulation.</p>
<p>I decided on Sunday that I had a few hours to work on this project and I wanted it finally finished. While the result is not exactly what I wanted, it will suffice.</p>
<p>What I&rsquo;ve built is a group of four LEDs that fade in and out in an inverse manner. While LED1 fades in, LED2 fades out and LED1 and LED3 work in synch, as do LED2 and LED4. So, when LED1 and LED3 fade out, LED2 and LED4 fade in and when LED2 and LED4 fade out, LED1 and LED3 fade in. It is random enough &ndash; and fast enough &ndash; that you can&rsquo;t really tell they&rsquo;re working inversely.<br />
<div id="attachment_123" class="wp-caption alignright" style="width: 310px"><a href="http://www.dmcole.net/wp-content/uploads/2009/05/digitalcandle-schematic-v2b.pdf" target="_new"><img src="http://www.dmcole.net/wp-content/uploads/2009/05/digitalcandle-schematic-v2b-300x257.jpg" alt="ATTiny13 drives 5 LEDs; production circuit (click to download PDF)" title="digitalcandle-schematic-v2b" width="300" height="257" class="size-medium wp-image-123"  border="0" /></a><p class="wp-caption-text">ATTiny13 drives 5 LEDs; production circuit (click to download PDF)</p></div></p>
<p>The fifth LED staying on all the time helps by keeping the candle from ever going completely dark. This effect would work just as well with only three LEDs, but the two extras throw off more light.</p>
<p>The finished code is at the end of this article.</p>
<p>In the prototype I&rsquo;m using 10mm warm white LEDs that are rated at 85,000 millicandles; they have a 3.3-volt forward voltage, so I&rsquo;m using 100-ohm, one-eighth watt resisters between the five pins of the microcontroller and the positive leg of the LED.</p>
<p>I have provided two circuit schematics; one is for a circuit to program and test the ATTiny13; the other is an operational circuit. I will be using this candle on my backyard railroad; you can see how I built the other flickering lights on the railroad <a href="http://www.45mm.com/lighting/flickering-big.html" target="_new">here</a> and you can assume I&rsquo;ll use a similar plastic-canistter/wood/glue/screws building technique for this.</p>
<p>These schematics don&rsquo;t detail the circuit that takes the raw Malibu 12-volt AC of my layout and turns it into filtered, five-volt DC for the microprocessor and LEDS; you can rest assured I built something eerily similar to this <a href="http://www.45mm.com/lighting/5v-DC.html" target="_new">circuit</a>.</p>
<p>I will build both circuits on a piece of RS <a href="http://www.radioshack.com/product/index.jsp?productId=2104052" target="_new">project board</a>, though I plan to attach the LEDs with one-inch long wire in order to be able to point them in various directions.</p>
<p>I&rsquo;ve provided a video of the LEDs, one scene where they&rsquo;re running on the breadboard bare and a second with a plastic canister, to give you an idea of how they will look on the layout.</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/PUSlyH5_0o4&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/PUSlyH5_0o4&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p95code2'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p952"><td class="code" id="p95code2"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*
* Digital candle V2
* -----------
* Use random numbers to emulate a flickering candle on five LEDs without hardware PWM 
* 
* David M. Cole &lt;dmcole at dmcole dot net&gt;
* License: 2009 Creative Commons Attribution-Noncommercial-Share Alike 3.0 U.S.
* Target: ATTiny13
* Compiler: AVR-GCC
*/</span>
&nbsp;
<span style="color: #339933;">#include &lt;avr/io.h&gt;											// Defines pins, po</span>
<span style="color: #339933;">#define led1_on PORTB |= 1 &lt;&lt; 0										// PortB0 = on</span>
<span style="color: #339933;">#define led1_off PORTB &amp;= ~(1 &lt;&lt; 0)									// PortB0 = off</span>
<span style="color: #339933;">#define led2_on PORTB |= 1 &lt;&lt; 1										// PortB1 = on</span>
<span style="color: #339933;">#define led2_off PORTB &amp;= ~(1 &lt;&lt; 1)									// PortB1 = off</span>
<span style="color: #339933;">#define led3_on PORTB |= 1 &lt;&lt; 2										// PortB2 = on</span>
<span style="color: #339933;">#define led3_off PORTB &amp;= ~(1 &lt;&lt; 2)									// PortB2 = off</span>
<span style="color: #339933;">#define led4_on PORTB |= 1 &lt;&lt; 3										// PortB3 = on</span>
<span style="color: #339933;">#define led4_off PORTB &amp;= ~(1 &lt;&lt; 3)									// PortB3 = off</span>
<span style="color: #339933;">#define led5_on PORTB |= 1 &lt;&lt; 4										// PortB4 = on</span>
<span style="color: #339933;">#define led5_off PORTB &amp;= ~(1 &lt;&lt; 4)									// PortB4 = off</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//	Declare variables</span>
<span style="color: #666666; font-style: italic;">//	==============================================</span>
	uint8_t y<span style="color: #339933;">,</span> z<span style="color: #339933;">,</span> i<span style="color: #339933;">,</span> j<span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//	==============================================</span>
&nbsp;
	<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			DDRB <span style="color: #339933;">=</span> <span style="color: #208080;">0b11111111</span><span style="color: #339933;">;</span>								<span style="color: #666666; font-style: italic;">// PortB all outputs</span>
 			<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">;;</span><span style="color: #009900;">&#41;</span>										<span style="color: #666666; font-style: italic;">// loop forever</span>
 				<span style="color: #009900;">&#123;</span>
					y <span style="color: #339933;">=</span> rand<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span><span style="color: #0000dd;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>						<span style="color: #666666; font-style: italic;">// bottom of first loop</span>
					z <span style="color: #339933;">=</span> rand<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">63</span><span style="color: #339933;">,</span><span style="color: #0000dd;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>						<span style="color: #666666; font-style: italic;">// top of first loop</span>
					<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> z<span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> y<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>						<span style="color: #666666; font-style: italic;">// first fade loop</span>
						<span style="color: #009900;">&#123;</span> 
							led1_off<span style="color: #339933;">;</span>
							led2_on<span style="color: #339933;">;</span>
							led3_off<span style="color: #339933;">;</span>					<span style="color: #666666; font-style: italic;">// set up for first fade</span>
							led4_on<span style="color: #339933;">;</span>
							led5_on<span style="color: #339933;">;</span>					<span style="color: #666666; font-style: italic;">// led5 is always on</span>
							<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>j<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> y<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
								<span style="color: #009900;">&#123;</span>
									<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&gt;</span> i<span style="color: #009900;">&#41;</span>
										<span style="color: #009900;">&#123;</span>
											led1_on<span style="color: #339933;">;</span>
											led2_off<span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">// turn off lamps that were on</span>
											led3_on<span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">// turn on lamps that were off</span>
											led4_off<span style="color: #339933;">;</span>
											led5_on<span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">// led5 is always on</span>
										<span style="color: #009900;">&#125;</span>
								<span style="color: #009900;">&#125;</span>
							<span style="color: #009900;">&#125;</span>						<span style="color: #666666; font-style: italic;">// end first fade loop </span>
					y <span style="color: #339933;">=</span> rand<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span><span style="color: #0000dd;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>						<span style="color: #666666; font-style: italic;">// bottom of second looop</span>
					z <span style="color: #339933;">=</span> rand<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">63</span><span style="color: #339933;">,</span><span style="color: #0000dd;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>						<span style="color: #666666; font-style: italic;">// top of second looop</span>
					<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> y<span style="color: #339933;">;</span> i <span style="color: #339933;">&gt;</span> z<span style="color: #339933;">;</span> i<span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span>						<span style="color: #666666; font-style: italic;">// second fade loop</span>
						<span style="color: #009900;">&#123;</span>
							led1_on<span style="color: #339933;">;</span>
							led2_off<span style="color: #339933;">;</span>
							led3_on<span style="color: #339933;">;</span>					<span style="color: #666666; font-style: italic;">// note lamps swap state</span>
							led4_off<span style="color: #339933;">;</span>					<span style="color: #666666; font-style: italic;">// from first loop</span>
							led5_on<span style="color: #339933;">;</span>					<span style="color: #666666; font-style: italic;">// led5 is always on</span>
							<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>j<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> y<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
								<span style="color: #009900;">&#123;</span>
									<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&gt;</span> i<span style="color: #009900;">&#41;</span>
										<span style="color: #009900;">&#123;</span>
											led1_off<span style="color: #339933;">;</span>
											led2_on<span style="color: #339933;">;</span>
											led3_off<span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">// and again, change state</span>
											led4_on<span style="color: #339933;">;</span>
											led5_on<span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">// led5 is always on</span>
										<span style="color: #009900;">&#125;</span>
								<span style="color: #009900;">&#125;</span>
						<span style="color: #009900;">&#125;</span>							<span style="color: #666666; font-style: italic;">// end second fade loop</span>
				<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.dmcole.net/index.php/digital-candle-%e2%80%93-version-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Digital candle — Version 1</title>
		<link>http://www.dmcole.net/index.php/digital-candle-%e2%80%94-version-1/</link>
		<comments>http://www.dmcole.net/index.php/digital-candle-%e2%80%94-version-1/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 21:03:17 +0000</pubDate>
		<dc:creator>dmcole</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[ATTiny13]]></category>
		<category><![CDATA[Digital candle]]></category>
		<category><![CDATA[LED]]></category>

		<guid isPermaLink="false">http://www.dmcole.net/?p=57</guid>
		<description><![CDATA[If you’ve visited my web site on backyard railroad illumination, you know about my fixation with creating light that flickers as though it were a fire (either from candle or a fireplace).
The first solution to that problem was to modify LED tea candles — readily available at crafts stores and even Walgreens — so that [...]]]></description>
			<content:encoded><![CDATA[<p>If you’ve visited my web site on <a href="http://www.45mm.com/lighting/" target="_new">backyard railroad illumination</a>, you know about my fixation with creating light that flickers as though it were a fire (either from candle or a fireplace).</p>
<div id="attachment_76" class="wp-caption alignright" style="width: 310px"><a href="http://www.dmcole.net/wp-content/uploads/2009/03/digitalcandle-schematic-v1.pdf" target="_new"><img src="http://www.dmcole.net/wp-content/uploads/2009/03/digitalcandle-schematic-v1-300x197.jpg" alt="Schematic of circuit to fade, flicker single LED (click to download PDF)" title="digitalcandle-schematic-v1" width="300" height="197" class="size-medium wp-image-76" border="0" /></a><p class="wp-caption-text">Schematic of circuit to fade, flicker single LED (click to download PDF)</p></div>
<p>The first solution to that problem was to modify LED tea candles — readily available at crafts stores and even Walgreens — so that they would work off of standard 12-volt garden lighting (aka: <a href="http://www.malibulights.com/index.php?action=subcategory&amp;pid=0&amp;did=1&amp;sid=9" target="_new">Malibu lighting</a>).</p>
<p>The dirty little secret of that method is that all the tea candles flicker at the same time. I&#8217;m not quite sure why this is so — perhaps the proprietary microcontroller used in those devices is time based and since they all start at the same time, they seem to work in synch? In any event, it does make looking at all the &#8220;fires&#8221; on my layout pulse at the same time.</p>
<p>So, in the back of my mind, I knew I wanted something besides tea lights to make flickering light on the layout. I kept looking around the net, and in January a reader of the backyard illumination site pointed me to an <a href="http://www.instructables.com/id/S2LGADIFN82WUKQ/" target="_new">Instructables</a> that showed a circuit to increase the current that could pass through a tea light, allowing up to four LEDs to be driven in the circuit.</p>
<p>The Instructables site provides a &#8220;related&#8221; window in the right-rail and along with the increased current circuit there were a couple of other &#8220;LED candles&#8221; that caught my fancy.</p>
<p>One, which by March seems to have been removed from the site, used the concept of the <a href="http://en.wikipedia.org/wiki/Linear_feedback_shift_register" target="_new">linear feedback shift register</a> to control the flickering. Unfortunately, it was written for a Pic12F675, not an AVR (reading the datasheets, I decided that an ATTiny13 would be the equivalent controller).</p>
<p>What I liked about this idea was that it utilized seven of the eight pins of the microcontroller — it drove five LEDs (which is five of the pins and one each for power and ground). There were other circuits on the ’Net and Instructables that used just one LED, but none used all five (this was in January).</p>
<p>So, I bought a handful of ATTiny13s at <a href="http://www.jameco.com/" target="_new">Jameco</a> and set about to build the circuit and convert the code.</p>
<p>I didn&#8217;t really get anywhere. So, I started writing my own code. For the first shot, I decided to control just a single LED (crawl before walking).</p>
<p>The circuit illustrated above and the code below do that. What&#8217;s different (it turns out) from what I&#8217;ve done here and what others around the ’Net have done is that I&#8217;m fading the LED from dark to bright in a random manner.</p>
<p>I do this without using hardware <a href="http://en.wikipedia.org/wiki/Pulse-width_modulation" target="_new">pulse width modulation</a> (PWM); I chose to skip hardware PWM because of the way the ATTiny13 is configured: the PWM pins are also the pins that are used for programming. To use hardware PWM I would have had to program the chip, power down the circuit, connect the LEDs, run the program and to debug, do the steps in the opposite order.</p>
<p>Easier to write my own PWM code, I thought <img src='http://www.dmcole.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  &#8230;</p>
<p>The code makes (to my eye, at least) a more realistic candlelight flicker. But, it is just one LED and while that might be enough for somebody else, I&#8217;ve got four more pins to use in this project and I&#8217;m going to figure out how to use them.</p>
<p>I&#8217;m working with another developer over at Ladyada forums and I hope to have a five-LED version of fading code work on an ATTiny13 shortly.</p>
<p>For now, though, here&#8217;s Version 1, the single LED fading digital candle:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p57code4'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p574"><td class="code" id="p57code4"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*
* DigitalCandle -- Version 1
* -----------
* Use random numbers to emulate a flickering candle on a single LED without hardware PWM 
* 
* David M. Cole &lt;cole@dmcole.net&gt;
* License: 2009 Creative Commons Attribution-Noncommercial-Share Alike 3.0 U.S.
* Target: ATTiny13
* Compiler: AVR-GCC
*/</span>
&nbsp;
<span style="color: #339933;">#include &lt;avr/io.h&gt;														// Defines pins, po</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//	Declare variables</span>
<span style="color: #666666; font-style: italic;">//	==============================================</span>
	uint8_t x<span style="color: #339933;">,</span> y<span style="color: #339933;">,</span> z<span style="color: #339933;">,</span> i<span style="color: #339933;">,</span> j<span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//	==============================================</span>
&nbsp;
	<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			DDRB <span style="color: #339933;">=</span> <span style="color: #208080;">0b11111111</span><span style="color: #339933;">;</span>										<span style="color: #666666; font-style: italic;">// PortB all outputs</span>
 			<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">;;</span><span style="color: #009900;">&#41;</span>												<span style="color: #666666; font-style: italic;">// loop forever</span>
 				<span style="color: #009900;">&#123;</span>
		 			x <span style="color: #339933;">=</span> <span style="color: #0000dd;">4</span><span style="color: #339933;">;</span>
					y <span style="color: #339933;">=</span> rand<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span><span style="color: #0000dd;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					z <span style="color: #339933;">=</span> rand<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">63</span><span style="color: #339933;">,</span><span style="color: #0000dd;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> z<span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> y<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>								<span style="color: #666666; font-style: italic;">// the fading in loop</span>
						<span style="color: #009900;">&#123;</span> 
							PORTB <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> x<span style="color: #339933;">;</span> 						<span style="color: #666666; font-style: italic;">// light on </span>
							<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>j<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> y<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
								<span style="color: #009900;">&#123;</span>
									<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&gt;</span> i<span style="color: #009900;">&#41;</span>
										<span style="color: #009900;">&#123;</span>
											PORTB <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span> <span style="color: #339933;">&lt;&lt;</span> x<span style="color: #339933;">;</span>	 		<span style="color: #666666; font-style: italic;">// light off </span>
										<span style="color: #009900;">&#125;</span>
								<span style="color: #009900;">&#125;</span>
							<span style="color: #009900;">&#125;</span>								<span style="color: #666666; font-style: italic;">// end fade in </span>
					y <span style="color: #339933;">=</span> rand<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span><span style="color: #0000dd;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					z <span style="color: #339933;">=</span> rand<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">63</span><span style="color: #339933;">,</span><span style="color: #0000dd;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> y<span style="color: #339933;">;</span> i <span style="color: #339933;">&gt;</span> z<span style="color: #339933;">;</span> i<span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span>								<span style="color: #666666; font-style: italic;">// the fading out loop</span>
						<span style="color: #009900;">&#123;</span>
							PORTB <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> x<span style="color: #339933;">;</span>							<span style="color: #666666; font-style: italic;">// light on </span>
							<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>j<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> y<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
								<span style="color: #009900;">&#123;</span>
									<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&gt;</span> i<span style="color: #009900;">&#41;</span>
										<span style="color: #009900;">&#123;</span>
											PORTB <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span> <span style="color: #339933;">&lt;&lt;</span> x<span style="color: #339933;">;</span>			<span style="color: #666666; font-style: italic;">// light off</span>
										<span style="color: #009900;">&#125;</span>
								<span style="color: #009900;">&#125;</span>
						<span style="color: #009900;">&#125;</span>									<span style="color: #666666; font-style: italic;">// end fade out</span>
				<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.dmcole.net/index.php/digital-candle-%e2%80%94-version-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
