int analogPin = 3; // potentiometer connected to analog pin 3
int val = 0;
int rLight = 0;
int wLight = 0;
void setup() {
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(3, INPUT);
analogWrite(5, 0);
analogWrite(6, 0);
analogWrite(9, 0);
analogWrite(10, 0);
}
void loop() {
//analogWrite(5, 0);
//analogWrite(6, 10);
//analogWrite(9, 0);
//analogWrite(10, 10);
delay(10);
int val = analogRead(analogPin);
rLight = map(val, 0, 511, 255, 0);
wLight = map(val, 512, 1023, 0, 255);
if(rLight>0){
analogWrite(5, rLight);
analogWrite(6,0);
}
if(rLight==0 || wLight==0){
analogWrite(5, 1);
analogWrite(6,0);
}
if(wLight>0){
analogWrite(5, 0);
analogWrite(6,wLight);
}
}