Using Millis to Turn On/Off Relay for a set interval

Firstly, I want to thank everyone for taking the time to have a look at my code and give me their advice. The opportunity to learn is truly appreciated. Sorry for the slow reply, between work, testing on a simulator, and finally on the hardware I've been busy all day

@gcjr The compressor flag is a good idea and I like the simplicity of the concept. This is something I could see myself writing / using in the future. I'm really a big fan of your enum function to allow for different states. I was not aware of this function and am really excited for the possibilities it offers. It is definitely staying in the code, thank you.

@gerivega The millis route is the path I originally wanted to take because it allows me to end the program at any point as it is never stuck in delay, so this is the solution. I have to admit this is much more complex on paper than I would have imagined. I'm certain that I would not have arrived at this on my own. I'm glad to have the opportunity to see the code and experience how it works. The bool condition works great, thank you so much for your effort here.

@StefanL38 As I mentioned a couple times, I'm new to programming and so was unaware that there was a standard convention for communicating issues with code. Now that you have brought it to my attention it makes very good sense. Programming is a science, and standard convention for communication is common among all fields of science.

Thanks again to all for your time and helpful comments!!

1 Like