How to blink an LED where OFF period is longer than ON period??

Hello Folks,

I am using the following code to blink an LED. For the life of me I can't figure out how to make the OFF period be 3 seconds when the ON is .5 seconds as below.

Many thanks for any clues.


// Which pins are connected to which LED
const byte greenLED = 12;
// Time periods of blinks in milliseconds (1000 to a second).
const unsigned long greenLEDinterval = 500
// Variable holding the timer value so far. One for each "Timer"
unsigned long greenLEDtimer;
void setup ()
pinMode (greenLED, OUTPUT);
greenLEDtimer = millis ();
} // end of setup
void toggleGreenLED ()
if (digitalRead (greenLED) == LOW)
digitalWrite (greenLED, HIGH);
digitalWrite (greenLED, LOW);
// remember when we toggled it
greenLEDtimer = millis ();
} // end of toggleGreenLED
void loop ()
// Handling the blink of one LED.
if ( (millis () - greenLEDtimer) >= greenLEDinterval)
toggleGreenLED ();

/* Other code that needs to execute goes here.
It will be called many thousand times per second because the above code
does not wait for the LED blink interval to finish. */

} // end of loop

Instead of toggling the LED, you either turn it on or turn it off depending on the current state. And, when you turn it on or off you change the period until the next change - depending on if you turned it on or off.

You know when you're changing the state of the LED, so why not use that decision point to change the interval as well?
Hint: it doesn't have to be "const".

Many thanks guys!

I think I get it now.