Turning On an LED randomly between 3 different specified Offtimes times

Hi, was wondering if anyone could help me with how I would go about turning on an LED for a 1 second ON time then OFF for either 1secs, 2 secs or 3 secs. .. I want this to be for the duration the circuit is on: but choose the off time between the 1,2 or 3sec randomly.
For example:
LED on for 1 secs
Off for 1, 2 or 3 secs
ON for 1 secs
Off for 1, 2 or 3 secs
ON for 1 secs
Off for 1,2 or 3 secs
(I want it to choose the off time randomly between the 3 values 1,2 or 3 secs each time)

Not asking you to write the code for this whole thing, I don't expect that
..just any help with how I would go about choosing 1,2 or 3 secs randomly.

IE. Let the OFF time be called 'Offtime()'
Now how would I choose an Offtime of 1 or 2 or 3 secs.

It seems like this would be very easy but I'm bloody stupid right now. So any help would be amazing :slight_smile:
Thanks in advance and apologies fo my stupidity.


Thanks for your reply iee448...and for the link...nice resource there that I'm going to do a lot of reading at now :slight_smile:

I probably shouldn't have made the off times sequential....

How would I choose randomly between three non sequential off times: for example off times of 4 secs, 7 secs and 14 secs?

Generate a random number of 0,1,2 with each corresponding to 4,7,14 seconds.

Thanks again IEE!