Struggling with switching Arduino and Random numbers

You need to use the if statement. Read up about this.
Read your timer signal and put it in a variable called signal.

At the end of the loop function save that variable is another variable called something like oldSignal.

in the body of the loop use an if statement to compare the value of signal and oldSignal.
If they are not the same something has changed. use another if to see the state of the variable signal. then you either turn off the LED or generate a new random number and turn it on.

You are better off writing this yourself as in that way you will learn something.