Programmable blinking LED function

Create a standalone function to,

Blink a LED ; LED ON time and OFF time to be individually programmable ; Without using delay();

I thought it was good to have a function as above to be re-used in codes requiring a blink LED function. The result was the code below. It works. Just wanted to know if it can be improved upon ?

    14 Dec 2016 

  Blinks a LED connected to a digital pin, without using the delay() function.

  The ON time and OFF time can be independently programmed

  The circuit:
   LED attached from pin 13 ( or any other pin as defined ) to ground.


void setup()


void loop()
  ledPrgOnOff(500, 500, 13);


// Function to blink an LED based on programmed On Times and Off times..

void ledPrgOnOff(long offPeriod, long onPeriod, byte ledPin )
  unsigned long currentMillis = millis();
  static unsigned long previousMillis = 0;
  static boolean ledState;
  static boolean onLED = 1;
  static boolean offLED = 0;
  if ( onLED )
    if (currentMillis - previousMillis >= offPeriod)
      ledState = HIGH;
      onLED = 0;
      offLED = 1;
      previousMillis = currentMillis;
  if ( offLED )
    if (currentMillis - previousMillis >= onPeriod)
      ledState = LOW;
      onLED = 1;
      offLED = 0;
      previousMillis = currentMillis;
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, ledState);     // Update the LED state

Just wanted to know if it can be improved upon ?

As noted, it could be a lot shorter.

The code can only operate one LED at a time, so it might be better to implement the code as a simple class, to improve its usefulness.

Thanks godivaPrima and AWOL.

On the aspect of converting the function to a class - is it something like making it as a re-entrant function so that more than one LED can be controlled simultaneously ? Frankly i don't have a working exposure to OOP and will need to first get the basics in place...