Hacked Touch Lamp

http://vimeo.com/moogaloop.swf?clip_id=1813199&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1
Hacked Touch Lamp from Mouse & the Billionaire on Vimeo.

Here’s the code, y’all!

 

int analogPin = 0;     // potentiometer wiper (middle terminal) connected to analog pin 3
                                     // outside leads to ground and +5V
int yVal = 0;   
int gVal = 0;
int rVal = 0;

int val = 0;
int ledPin = 13;
int yLed = 11;
int gLed = 10;
int rLed = 9;

void setup() {
  Serial.begin(9600);          //  setup serial
  pinMode(yLed, OUTPUT);
}

void loop() {
  val = analogRead(analogPin);    // read the input pin
  yVal = min(val, 255);
  gVal = max(256, (min(val, 511)));
  rVal = max(512, (min(val, 756)));

  analogWrite(yLed, yVal);
  analogWrite(gLed, gVal);
  analogWrite(rLed, rVal);
   
}