//Brian Putz
//Light Theremin v. 0.1.2
//October 1st, 2010
//Pcomp
//
//Ambient light theremin controlled by light. Use light to fade in and //out specific light in a specified pattern
//Defined Light inputs
int ledPin = 5;
int ledPin2 = 6;
int ledPin3 = 9;
//Define val of sensor
int val = 0;
void setup(){
pinMode(ledPin,OUTPUT);
}
void loop(){
//fade light in
for(int i =0; i<=255; i++){
//Value of input from light sensor
val = analogRead(0);
//Output light w. sensor value being added to the amount of fade
analogWrite(ledPin, i+val); // Blue LED
//delay fade 20 ms
delay(20);
}
for(int i =0; i<=255; i++){
//Value of input from light sensor
val = analogRead(0);
//Output light w. sensor value being added to the amount of fade
analogWrite(ledPin2, i+val);//Green LED
//delay fade 20 ms
delay(20);
}
for(int i =0; i<=255; i++){
//Value of input from light sensor
val = analogRead(0);
//Output light w. sensor value being added to the amount of fade
analogWrite(ledPin3, i+val); //Red LED
//delay fade 20 ms
delay(20);
}
for(int i =255; i>=255; i--){
//Value of input from light sensor
val = analogRead(0);
//Output light w. sensor value being added to the amount of fade
analogWrite(ledPin, i+val); // Blue LED
//Value of input from light sensor
delay(20);
}
for(int i =255; i>=255; i--){
//Value of input from light sensor
val = analogRead(0);
//Output light w. sensor value being added to the amount of fade
analogWrite(ledPin2, i+val);//Green LED
//delay fade 20 ms
delay(20);
}
for(int i =255; i>=255; i--){
//Value of input from light sensor
val = analogRead(0);
//Output light w. sensor value being added to the amount of fade
analogWrite(ledPin3, i+val); //Red LED
//delay fade 20 ms
delay(20);
}
}
Comments
You can follow this conversation by subscribing to the comment feed for this post.