I have some code I was hoping someone could review to see if there is an optimal way to implement it. Basically, I am turning on/off a sign with a fade and flicker effect to simulate that it is not working properly. After effects occur the sign will stay on/off for a period of time (for testing purposes…it is 5 seconds). The fade-in/out is a randomized number to increase/decrease brightness, never to exceed 255 or go below 0. The flicker time is another randomized number and if the time does not exceed the current flicker interval, brightness will be zero, thus creating the flicker effect. The timer for the light to stay on/off occurs after the fade/flicker effects complete.
I did not create from scratch but modified code examples that are already out in the world. A lot of trial and error to get it to do what I wanted. A few nested ifs and repetitive code, and I am not sure if the code could be less cumbersome.
This is more of a learning exercise than a feature request or anything like that. Basically, I am exploring the art of the possible. Any guidance would be appreciated.
Thanks in advance.
justGuitar.ino (3.52 KB)