Hey!
I have 4 LEDs that I want to fade in in sequence. So first Led1, then Led2, then Led3 and then Led4. but I want to make it with one twist on the potentiometer.
So first ¼ should be Led1 to full, then stay there when Led2 fades in on the 2/4 and so on.
But I haven't found a way to tell them what part of the potentiometer's values they should lid on.
Any one have a solution, or a article I can read on the subject?
Thanks
The code so far: (LEDs named after color, and a lot of code just copied, so it's some tips in it... :-[ )
int ledR = 9;
int ledY = 6;
int ledG = 5;
int ledB = 3;// the pin that the LED is attached to
int brightness = 0; // how bright the LED is
int analogPin = 0; // potentiometer connected to analog pin 3
int val = 0; // variable to store the read value
int fadeAmount = 0;
void setup() {
// declare pin 9 to be an output:
pinMode(ledR, OUTPUT);
pinMode(ledY, OUTPUT);
pinMode(ledG, OUTPUT);
pinMode(ledB, OUTPUT);
}
void loop() {
val = analogRead(analogPin); // read the input pin
analogWrite(ledR, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
analogWrite(ledY, val / 4);
analogWrite(ledG, val / 4);
analogWrite(ledB, val / 4);
}