Another way would be to use a timer module.

You can check the timer overflow bit and increment a variable at each overflow.

Then, you can ON and OFF the LED at any desired time using this variable.


--------------------