
The screen looks like the above and the background bogs up and down. A lightning flash can happen and tests successfully.
However, the SetTimeout() timer that has lightning flash every now and then is not working.

Here is where the animate() function happens and where the timeout is called and it doesn't work.

Here is where the lightning effect is coded and it works successfully if there is no timeout.