concept question: How to keep blinky blinking while continue with loop

I want to control the rate of blinking LED based on parameters. But how can I check the parameters while the code is "locked up" in looping in control of blinking off and on of LED?

that is my immediate practical need. Leads to think can two/multiple routines be running at the same time on a conceptual understanding question?

You don't use delay. Instead you build a state machine based on millis(). millis() provides a time-ticker. You store the value of millis() do some stuff, then check the value to see if it is time to turn the LED on. Store the new value, do stuff, check to see if it is time to turn the LED off.

Start with the "Blink without delay()" example included with the IDE.

hi James, Thanks, got your idea. Will try it out.

on the conceptual front, what if the rest of the routine can take unpredictable time, can this potentially run into a situation where the blinking rate may not be accurate or as expected. This is not mission critical right now for me, but curious nevertheless.

on a similar front, does this mean that in arduino there are no such thing as "parallel routines" not sure if wording is correct..

Thanks..

on the conceptual front, what if the rest of the routine can take unpredictable time, can this potentially run into a situation where the blinking rate may not be accurate or as expected. This is not mission critical right now for me, but curious nevertheless.

You could use hardware timer to keep the led blinking - http://www.arduino.cc/playground/Main/MsTimer2 -

If the frequency is not too high you could even do some more in the timer2 interrupt.

thanks james, I found the arduino example here http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay

joefly:
on the conceptual front, what if the rest of the routine can take unpredictable time, can this potentially run into a situation where the blinking rate may not be accurate or as expected.

Either use a Timer interrupt, or better yet, break down the larger tasks so that there isn't as much time spent in one area.

joefly:
on a similar front, does this mean that in arduino there are no such thing as "parallel routines" not sure if wording is correct..

There is no concept of "threads" when using an Arduino. Unlike modern microprocessors, such as the one in your PC or maybe your smartphone, the Arduino uses a microcontroller that has no ability to manage "threads." You get 1 thread.

So by using a technique where you create a state machine and do tasks time based on how much time has passed, you start to emulate a threaded architecture. If gives the illusion of multitasking.

May I suggest analogWrite() (hardware pwm) to set the led brightness, and a timer library (I wrote SimpleTimer, which is one of many on arduino playground) to manage (pseudo) parallel functions execution.

My .02€

Sorry, misread the initial question. Forget analogWrite, led blink should be implemented as a timed function call, as explained in BlinkWithoutDelay tutorial...