<?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>Mud and Mayhem</title>
	<atom:link href="http://www.mudandmayhem.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mudandmayhem.com</link>
	<description>matt&#039;s experiments site</description>
	<lastBuildDate>Sat, 04 Feb 2012 22:44:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Example Mood Light #1</title>
		<link>http://www.mudandmayhem.com/blog/2012/02/04/189/</link>
		<comments>http://www.mudandmayhem.com/blog/2012/02/04/189/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 22:42:21 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Arduino]]></category>

		<guid isPermaLink="false">http://www.mudandmayhem.com/?p=189</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: cpp; title: ; notranslate">

// Make variables for individual LEDs
int r = 0;
int g = 0;
int b = 0;

// Make variable to store incoming sensor value
int sVal = 0;

int sStart = 0;

// Set Pins Locations
int sPin = 0;  //Sensor Pin
int rLed = 3;
int gLed = 5;
int bLed = 6;

void setup(){
  Serial.begin(9600);
  pinMode(sPin,INPUT);

  //Calibrate light sensor when it first starts up
  sStart = analogRead(sPin);

  //the rest of the pins are assumed OUTPUT
}

void loop(){
  //read sensor and change sVal to it
  sVal = analogRead(sPin);
  Serial.print(&quot;incoming = &quot;);
  Serial.print(sVal);
  Serial.print(&quot;, &quot;);
  sVal = map(sVal,10,sStart,0,255);
  sVal = constrain(sVal,0,255);

  //send value to computer so we can adjust our code
  Serial.println(sVal);

  if(sVal &lt;= 64)
  {
    digitalWrite(rLed,HIGH);
    digitalWrite(gLed,LOW);
    digitalWrite(bLed,LOW);
  }
  else if(sVal &lt;= 128)
  {
    digitalWrite(rLed,LOW);
    digitalWrite(gLed,HIGH);
    digitalWrite(bLed,LOW);
  }
  else if(sVal &lt;= 192)
  {
    digitalWrite(rLed,LOW);
    digitalWrite(gLed,LOW);
    digitalWrite(bLed,HIGH);
  }
  else
  {
    for(int fadeValue = 0 ; fadeValue &lt;= 255; fadeValue +=5) {
      // sets the value (range from 0 to 255):
      analogWrite(rLed, fadeValue);
      analogWrite(gLed, fadeValue);
      analogWrite(bLed, fadeValue);

      tone(9, fadeValue);
      // wait for 30 milliseconds to see the dimming effect
      delay(30);
    } 

    // fade out from max to min in increments of 5 points:
    for(int fadeValue = 255 ; fadeValue &gt;= 0; fadeValue -=5) {
      // sets the value (range from 0 to 255):
      analogWrite(rLed, fadeValue);
      analogWrite(gLed, fadeValue);
      analogWrite(bLed, fadeValue);
      tone(9, fadeValue);
      // wait for 30 milliseconds to see the dimming effect
      delay(30);
    }
    noTone(9);
  }

}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mudandmayhem.com/blog/2012/02/04/189/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

