Henry_Best:
I'd use:if (timeout(&count1, 500UL )) { //has the timing period ended?
led1State = !led1State;//Invert Led1State, HIGH becomes LOW and LOW becomes HIGH.
digitalWrite(led1Pin, led1State);//turn LED on or off, as defined by led1State.
}
Tempting though it be to make it that concise, my bias is to provide bullet-proof code. "led1State" has been defined as an "int" instead of a boolean, as LOW and HIGH appear to be defined as such. Using the "!" operator on "int" values is particularly dangerous. Do you know what !HIGH is? Have you tried it?
Henry_Best:
I'd also add an explanation that, although this code only blinks LEDs, the principle can be use to time anything.
Indeed it can and that is most certainly the intent. The point is that people are generally referred to "Blink without delay" as the reference for performing any timed function.