Triple Blink and Fade
Description:
I combined the blink code and fade code so that one Potentiometer controlled the blink of all 3 LEDs and another Potentiometer controlled fad of all 3 LEDs.
Components Used:
1- Arduino Uno
1- Breadboard
3- 220 Ω Resistor
3- Potentiometers
3- LEDs (Blue, Green, Red)
1- Diffuser Sculpture
Code:
/*
* one pot fades one 3 leds
* one pot blinks 3 leds
* modified version of AnalogInput
* by DojoDave <http://www.0j0.org>
* http://www.arduino.cc/en/Tutorial/AnalogInput
*/
int potPin2 = 2; // select the input pin for the fade potentiometer
int potPin1 = 1; // select the input pin for the blink potentiometer
int ledPin9 = 9; // select the pin for the LED
int ledPin10 = 10; // select the pin for the LED
int ledPin11 = 11; // select the pin for the LED
int val = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600);
}
void loop() {
val = analogRead(potPin1); // read the value from the sensor, between 0 - 1024
Serial.println(val);
analogWrite(ledPin9, val/4); // analogWrite can be between 0-255
analogWrite(ledPin10, val/4); // analogWrite can be between 0-255
analogWrite(ledPin11, val/4); // analogWrite can be between 0-255
val = analogRead(potPin2); // read the value from the sensor
delay(val); // stop the program for some time
digitalWrite(ledPin9, LOW); // turn the ledPin off
digitalWrite(ledPin10, LOW); // turn the ledPin off
digitalWrite(ledPin11, LOW); // turn the ledPin off
delay(val); // stop the program for some time
}
- Login to post comments