<?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>Volts and Bytes<title>&#187; ATTiny45</title>
</title>
	<atom:link href="http://voltsandbytes.com/tag/attiny45/feed/" rel="self" type="application/rss+xml" />
	<link>http://voltsandbytes.com</link>
	<description>Microcontroller projects, tutorials, and other electronics stuffs...</description>
	<lastBuildDate>Tue, 31 Aug 2010 09:57:05 +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>8-pin AVR based Mood Lamp</title>
		<link>http://voltsandbytes.com/8-pin-avr-based-mood-lamp/</link>
		<comments>http://voltsandbytes.com/8-pin-avr-based-mood-lamp/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 15:04:59 +0000</pubDate>
		<dc:creator>jer</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Atmel]]></category>
		<category><![CDATA[ATtiny]]></category>
		<category><![CDATA[ATTiny45]]></category>
		<category><![CDATA[AVR]]></category>
		<category><![CDATA[LED]]></category>
		<category><![CDATA[Mood Lamp]]></category>
		<category><![CDATA[PWM]]></category>
		<category><![CDATA[RGB]]></category>
		<category><![CDATA[RGB LED]]></category>

		<guid isPermaLink="false">http://voltsandbytes.com/?p=212</guid>
		<description><![CDATA[I got a sample of a RGB LED (Red Green Blue Light Emitting Diode). So, I decided to make something fun out of it. Using an 8-pin AVR microcontroller, ATtiny45, I made a simple prototype to control the RGB LED using PWM or Pulse Width Modulation. Then, I put the prototype inside a translucent candle [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="aligncenter size-full wp-image-219" title="mood-lamp" src="http://voltsandbytes.com/wp-content/uploads/2010/07/mood-lamp.png" alt="" width="588" height="248" /></p>
<p>I got a sample of a RGB LED (Red Green Blue Light Emitting Diode). So, I decided to make something fun out of it. Using an 8-pin AVR microcontroller, ATtiny45, I made a simple prototype to control the RGB LED using PWM or Pulse Width Modulation.<span id="more-212"></span></p>
<p style="text-align: center;"><img class="size-full wp-image-217 alignnone" title="RGB" src="http://voltsandbytes.com/wp-content/uploads/2010/07/RGB.jpg" alt="" width="519" height="389" /></p>
<p>Then, I put the prototype inside a translucent candle vase. The vase diffused the light from the RGB very nicely and below is the video of the result.</p>
<p style="text-align: center;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="350" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/AVme_rwakCg" /><embed type="application/x-shockwave-flash" width="425" height="350" src="http://www.youtube.com/v/AVme_rwakCg"></embed></object></p>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-4129695434726741";
google_ad_slot = "5940435964";
google_ad_width = 468;
google_ad_height = 15;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p style="text-align: left;">I soldered a potentiometer to ATtiny45 to provide an input to its on-chip ADC or analog-to-digital converter. The rate of color transitions of the RGB LED can, then, be controlled by adjusting the potentiometer.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-214" title="mood-potentiometer" src="http://voltsandbytes.com/wp-content/uploads/2010/07/mood-potentiometer.jpg" alt="" width="519" height="389" /></p>
<p>The following are the pictures of the prototype. No printed circuit boards were used to simplify the project. The project is powered by two AA batteries.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-215" title="moodprototype1" src="http://voltsandbytes.com/wp-content/uploads/2010/07/moodprototype1.jpg" alt="" width="519" height="389" /></p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-216" title="prototype2" src="http://voltsandbytes.com/wp-content/uploads/2010/07/prototype2.jpg" alt="" width="519" height="389" /></p>
<p style="text-align: left;">Below is the schematic of the prototype.</p>
<p style="text-align: center;"><img class="aligncenter size-large wp-image-218" title="sch" src="http://voltsandbytes.com/wp-content/uploads/2010/07/sch-600x341.jpg" alt="" width="600" height="341" /></p>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-4129695434726741";
google_ad_slot = "5940435964";
google_ad_width = 468;
google_ad_height = 15;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>The following is the source code for the project. The compiler that I used is WinAVR.</p>
<blockquote><p>#include &lt;avr/io.h&gt;<br />
#define F_CPU 1000000UL<br />
#include &lt;util/delay.h&gt;</p>
<p>int main(void)<br />
{ unsigned char a=0,b=0,c=0,aa=0,bb=0,cc=0,temp;<br />
 DDRB=0xFF;<br />
 PORTB=0xFF;</p>
<p>//initialize ADC<br />
 ADMUX=0b00100011;<br />
 ADCSRA=0b10000100;</p>
<p>//Set OC0A on Compare Match, clear OC0A at BOTTOM<br />
 TCCR0A|=(1&lt;&lt;COM0A1); <br />
 TCCR0A|=(1&lt;&lt;COM0A0); <br />
 //Set OC0B on Compare Match, clear OC0B at BOTTOM<br />
 TCCR0A|=(1&lt;&lt;COM0B1); <br />
 TCCR0A|=(1&lt;&lt;COM0B0);<br />
 //Fast PWM, TOP=0xFF, Update of OCRx at BOTTOM<br />
 TCCR0A|=(1&lt;&lt;WGM01);     <br />
 TCCR0A|=(1&lt;&lt;WGM00);<br />
 //clkI/O/(No prescaling)<br />
 TCCR0B&amp;=~(1&lt;&lt;WGM02); <br />
 TCCR0B&amp;=~(1&lt;&lt;CS02);  <br />
 TCCR0B&amp;=~(1&lt;&lt;CS01);<br />
 TCCR0B|=(1&lt;&lt;CS00);</p>
<p>OCR0A=0&#215;00;<br />
 OCR0B=0&#215;00;</p>
<p>//PWM1B: Pulse Width Modulator B Enable<br />
 GTCCR|=(1&lt;&lt;PWM1B);<br />
 //OC1x Set on compare match. Cleared when TCNT1= $00.<br />
 GTCCR&amp;=~(1&lt;&lt;COM1B1);<br />
 GTCCR|=(1&lt;&lt;COM1B0);<br />
 //clock select bits<br />
 TCCR1&amp;=~(1&lt;&lt;CS13);<br />
 TCCR1|=(1&lt;&lt;CS12);<br />
 TCCR1&amp;=~(1&lt;&lt;CS11);<br />
 TCCR1|=(1&lt;&lt;CS10);</p>
<p>//OCR1B=0xFF;<br />
 //OCR1C=0xFF;</p>
<p>while(1)<br />
 { ADCSRA |= (1&lt;&lt;ADSC);<br />
  while((ADCSRA&amp;0&#215;10)==0&#215;00);<br />
  temp=ADCH;</p>
<p>OCR0A=c;<br />
  OCR0B=b;<br />
  OCR1B=~a;</p>
<p>while(temp&gt;0)<br />
  { temp&#8211;;<br />
   _delay_ms(1);<br />
  }</p>
<p>if(aa==0)<br />
  { a=a+1;<br />
   if(a==0xFF)<br />
   aa=1;<br />
  }</p>
<p>  if(aa==1)<br />
  { a=a-1;<br />
   if(a==0)<br />
   aa=0;<br />
  }</p>
<p>if(bb==0)<br />
  { b=b+3;<br />
   if(b==0xFF)<br />
    bb=1;<br />
  }</p>
<p>  if(bb==1)<br />
  { b=b-3;<br />
   if(b==0)<br />
    bb=0;<br />
  }</p>
<p>if(cc==0)<br />
  { c=c+5;<br />
   if(c==0xFF)<br />
    cc=1;<br />
  }</p>
<p>  if(cc==1)<br />
  { c=c-5;<br />
   if(c==0)<br />
    cc=0;<br />
  }<br />
 }<br />
}</p></blockquote>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-4129695434726741";
google_ad_slot = "5940435964";
google_ad_width = 468;
google_ad_height = 15;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://voltsandbytes.com/8-pin-avr-based-mood-lamp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
