/*
* one pot controls brightness another how fast the leds blink.
* modified version of AnalogInput
* by DojoDave <http://www.0j0.org>
* http://www.arduino.cc/en/Tutorial/AnalogInput
*/
int blinkPotPin = 1; // select the input pin for the potentiometer to control blink
int brightPotPin = 0; // select the input pin for the potentiometer to control brightness
int redPin = 9; // select the pin for the LEDs
int greenPin = 10;
int bluePin = 11;
int valBright = 0; // variable to store the value coming from the Bright Pot
int valBlink = 0; // variable to store the value coming from the Blink Pot
void setup() {
pinMode(redPin, OUTPUT); // declare the Pins as an OUTPUT
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
Serial.begin(9600);
}
void loop() {
valBright = analogRead(brightPotPin); // read the value from the bright sensor, between 0 - 1024
Serial.println(valBright);
analogWrite(redPin, valBright/4); // analogWrite can be between 0-255
analogWrite(greenPin, valBright/4);
analogWrite(bluePin, valBright/4);
valBlink = analogRead(blinkPotPin); // read the value from the Blink Sensor
delay(valBlink); // stop the program for some time
analogWrite(redPin, 0); // turn the ledPin off
analogWrite(greenPin, 0);
analogWrite(bluePin, 0);
delay(valBlink);
}