The Schematic
The Code
[sourcecode language="java"]
// p is our potentiometer
// r, g, & b our led's
int r=10,g=11,b=12,p=1,pval=0;
void setup(){
Serial.begin(9600);
pinMode(r,1);
pinMode(g,1);
pinMode(b,1);
}
void loop(){
// read the potentiometer
pval=analogRead(p);
// pass the value to cycle function
cycle(pval);
}
void cycle(int interval){
// map the pot value to something
// more managable
interval=map(interval,1,1023,30,300);
// write to serial for debugging
Serial.println(interval);
// flash values to rgb pins
flashPin(r,interval);
flashPin(g,interval);
flashPin(b,interval);
}
void flashPin(int pin,int interval){
// turn led on
digitalWrite(pin,1);
// read interval val from pot
delay(interval);
// turn led off
digitalWrite(pin,0);
delay(interval);
}
[/sourcecode]
The Implementation
http://youtu.be/YZBKMzh6Bg4