Hi there, I would like to use a linear potentiometer to control one led gradually darken, another is gradually brightened. Could I get some hints for that? I know how to use a linear potentiometer to controls led in one direction of brightness change, but have no idea how to use it to make two different directions of brightness change. Any advice would be helpful. Thanks in advance!
If I read your question right you want to, simultaneously, brighten one strip and dim the other?
brightness = analogRead(linearPot) / 4;
analogWrite(stripA, brightness);
analogWrite(stripB, 255 - brightness);
I assume you know how to fade on LED with a pot and PWM?
If you wire an LED between +5V and the Arduino output (instead of between the output and ground) the fading/PWM will be reversed so zero is full-on and 255 is full-off. So... You can wire two LEDs back-to-back (each with a current limiting resistor) and they will fade in opposite directions. (But, it may not "look" linear.)
Or you an invert the PWM by subtracting the PWM value from 255 to make it fade in the opposite direction.
Thanks for your advice. Actually, I'm trying to make a homemade linear potentiometer, but quite new to it.
If the resistance of the resistor is from 0 to half of the whole resistance, the greater the resistance, the brightener the LED1, the darken the LED2;
If the resistance of the resistor is from half of the whole resistance to the whole resistance, the greater the resistance, the brightener the LED2, the darken the LED1.
And I'm also not sure whether it's possible to detect half of the whole resistance as the borderline...