first a little description of my idea: it's a lamp with several led's (10 to 15). if i mention "fade" later it means to fade in and out once (very calm like the apple mac book light). after you switch on the lamp, it takes a few seconds, then the first led fades. then another led after a few seconds. then maybe two at a time... then more and more. then it should be again less and then more again in a loop. do you get the impression?
i was thinking about controlling every single led. i'm working with the arduino uno board and white 5mm leds.
I'm very new to all the programming and electronics. i already found out, that fading with cosinus is much nicer than just with fadeamound (but a little too fast by now).
now the specific problem: how can i delay the start of the fading? or maybe let every led fade every 5 seconds, but start at a different time...
the problem is not fading a single led. i have problems with the shifted starts and breaks.
any tricks and help???
thanks for taking time to help!
some programming to have something to talk about...
int value, value2 ;
int ledpin = 3; // light connected to digital pin 3
int ledpin2 = 5; // light connected to digital pin 5
int periode = 2000;
int displace = 500;
// nothing for setup
time = millis();
value = 128+127*cos(2*PI/periode*time);
value2 = 128+127*cos(2*PI/periode*(displace-time));
analogWrite(ledpin, value); // sets the value (range from 0 to 255)
analogWrite(ledpin2, value2); // sets the value (range from 0 to 255)
Look at the blink without delay example built in to your arduino environment under examples.
Now in place of turning the LEDs on and off just change the value you write to the PWM. You can have lots of LEDs all fading at different rates.
Then use Boolean variables to switch and decide if the LED value is to be incremented (fading up) or decremented (fading down).
Also look up the concept of “state machines” which blink without delay is a simple example.
Is there a simple way of telling me how to integrate random numbers for length of LED being lit/unlit? I see the code in Getting Started With Arduino (p108) and I have no idea where to put it. I want to do the same as original post, each LED different value with random numbers.
I have following code to try to work into sketch:
long randnum = random(0, 100);
I see the code in Getting Started With Arduino (p108) and I have no idea where to put it.
You can see it but we can't. You need to post the code you are having trouble with along with a question of what you want to do. Preferably in the programming section of the forum.