Go Down

Topic: Sticky - Blink Two LEDs, independent, no delay (Read 15410 times) previous topic - next topic


Nov 21, 2011, 07:00 pm Last Edit: Nov 21, 2011, 07:06 pm by Jassper Reason: 1
This might be a better solution ;) (at least for more complicated issues)



 In changing the title and in writing the explanation keep in mind that the most important concept here is the fact that the code is implementing a 'delay' without using the 'delay()' function.  The fact that one or more LEDs are blinking is not really what this is all about.

The blinking of an LED is an example of what can be done with any kind of delay technique.  The blinking of an LED while also doing something else is an example of what can be done when the use of delay() is eliminated, as is the independent blinking of two LEDs.

It also helps introduce how to handle/work with asynchronous events which to my mind is the crux of loop().

Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts


In my mind the reason for this "sticky" was to extend the Blink without delay() tutorial to two LEDs. Thus the explanation of avoiding using delay() is assumed covered. This was to help make the mental leap from the single LED to the general case. (Some people cant even make the leap from a LED to a motor ...)

No, it is not a complete example on the "best" way to blink a LED. No, it wasnt an example on how to implement polled multithread programming.


Thus the explanation of avoiding using delay() is assumed covered.

Just make sure that if the word 'delay' is used in the title that it includes the parentheses.  Actually it would probably be better to indicate what is being used rather than what is not being used.  How about 'Blink Two LEDs independently without blocking' or 'Blink Two LEDs independently using millis()' ?


Go Up