I wrote a simple snippet of code to control and fade the cabin lights in my airplane. The idea is that when both doors are closed, the computer waits for 30 seconds and then fades the lights down. When the doors are opened the lights fade up immediately.
The program was easy to write and everything works great except for the part where the computer waits 30 seconds. I'm a big time newbie and have been spending hours trying to figure out what the problem is. These have been my attempts:
My first code tried to use a delay() function which slowed the fade to a crawl, even when I tried to isolate the delay from the fade function.
After much reading I tried various iterations of the millis() function. It either ends ups slowing down the fade to a crawl or crashing the whole thing so that the lights won't do anything.
I've tried while(), if(), multiple if()s and other things, all to no avail. Can someone please put me out of my misery and show me how to do it right? Thanks