Go Down

Topic: problem fading and blinking leds simultaneously with millis (Read 1 time) previous topic - next topic

erinbanwell

thanks. I'm betting you are referring to the delay vs. millis problem, eh? Thanks again for your help!

KirAsh4


erinbanwell

what i mean is, if I add delay the fade gets all chopped up, so I need to work out a millis timer instead of delay. correct?

KirAsh4

No, the delay nor millis() has nothing to do with it getting chopped up.  Think about it for a moment.  You are using pin 10 for the fade, and you are cycling from 0 to 13 to turn LEDs on/off ...  0 to 13 ... pin 10 ... pin 10 ... 0 to 13 ...  Write it out if you don't quite see it.  Start with x == 0.  Your loop goes 0, 1, 2, 3 ... 8, 9, ??  What just happened?

KirAsh4

I'm not trying ot be a PITA here, but I don't want to just hand you the answer either.  This is how you learn (at least I do), by figuring out where my mistakes are.  In your case, just step through your loop one by one, and hopefully you'll understand why your fade on pin 10 gets all chopped up.  It's not that hard.  If you really can't tell, I'll try to explain it.

Go Up