<?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>uRaNGaTaNG &#187; dimm</title>
	<atom:link href="http://www.rngtng.com/tag/dimm/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rngtng.com</link>
	<description>TobiTobes Tech Weblog featuring Ruby, Rails, Web development, Arduino, Processing, Geekstuff and more...</description>
	<lastBuildDate>Thu, 02 Sep 2010 20:42:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Arduino: Fade and pulse a LED with just using a DigitalPort</title>
		<link>http://www.rngtng.com/2009/05/17/arduino-fade-and-pulse-a-led-with-just-using-a-digitalport/</link>
		<comments>http://www.rngtng.com/2009/05/17/arduino-fade-and-pulse-a-led-with-just-using-a-digitalport/#comments</comments>
		<pubDate>Sun, 17 May 2009 13:40:45 +0000</pubDate>
		<dc:creator>tobi</dc:creator>
				<category><![CDATA[Arduino & Co.]]></category>
		<category><![CDATA[dimm]]></category>
		<category><![CDATA[fade]]></category>
		<category><![CDATA[led]]></category>

		<guid isPermaLink="false">http://www.rngtng.com/?p=90</guid>
		<description><![CDATA[This is a nice experiment I did to fade and pulse a LED by just using a digital port. Digital? On/Off, 1/0 &#8211; how can this work? Well it does, check this out: The key is, I&#8217;m switching the LED on &#38; off very fast which appears the human eye as it&#8217;s on all the [...]]]></description>
			<content:encoded><![CDATA[<p>This is a nice experiment I did to fade and pulse a LED by just using a <em>digital</em> port. Digital? On/Off, 1/0 &#8211; how can this work? Well it does, check this out:</p>
<p><a href="http://www.rngtng.com/2009/05/17/arduino-fade-and-pulse-a-led-with-just-using-a-digitalport/"><em>Click here to view the embedded video.</em></a></p>
<p>The key is, I&#8217;m switching the LED on &amp; off very fast which appears the human eye as it&#8217;s on all the time (similar to a LED Matrix). Now, I change the time period between switching the LED on and off. Is the off period time longer, the LED lights low, is the off period time short, the LED lights high. Fading the period time, makes the LED pulse&#8230; nice!</p>
<p>Check this (still quite ugly) code:</p>
<pre class="brush: cpp;">
int ledPin = 13;      // LED connected to digital pin 13
int value = LOW;    // previous value of the LED
long cnt = 0;         // will store last time LED was updated
long low = 0;         // interval at which to blink (milliseconds)
long high = 1000; // interval at which to blink (milliseconds)
int op = 3;
long a = 0;

void setup()
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
}

void loop()
{
  a += op;
  blinkl( a+30, 10 );
  if( a &gt; 200 || a &lt; 0 ) op *= -1;
}

void blinkl(long low, long high )
{
  int c = 5;
  while ( c &gt; 0 ) {
   blink( low, high );
   c-=1;
 }
}

void blink( long low, long high )
{
  long period = 4000;
  long pt = period * high / (low + high );
  int value = LOW;
  digitalWrite(ledPin, value);

  while( period &gt; 0 ) {
    if (period &lt; pt &amp;&amp; value == LOW ) {
      value = HIGH;
      digitalWrite(ledPin, value);
    }
    period -= 1;
  }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rngtng.com/2009/05/17/arduino-fade-and-pulse-a-led-with-just-using-a-digitalport/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
