I'm almost embarrassed to admit that I'm building yet another chicken coop automation project. This is my first project that involves multiple inputs an outputs. So far I've really only flashed LED's, faded RGB LED's, controlled servos, run OLED screen demos and stuff like that.
Just wondering how I should structure this. I have all the bits and pieces of code, I'm just not sure what the best way to organize it would be. Here are the basic blocks:
nRF24 listen/transmit (another arduino in the house will request info and send commands back to this one)
check LDR // there will be two LDR's with a north/south divider between them, equal values indicates noon
If sun is over head and door is closed, open it, toggle dooropen boolean, transmit door has been opened notification to command unit // We don't let them free range until around noon otherwise they lay eggs all over the yard
Else if no sunlight present and door open is true, close it, toggle door open boolean, transmit door has been closed notification to command unit
Check temp/humidity sensor
if temp > 70, run fan
else if temp < 0, turn on heat lamp (they were fine at -30 this winter so zero degrees is no problem 8))
else if temp <70 && temp > 0 turn off fan, turn off lamp
Actuate food dispenser (once daily or maybe manually via command unit for now)
My question is would multiple loops be advantageous here? It's going to be listening to the RF unit most of the time, and then checking the sensors maybe every five minutes.
Could I have a main loop that listens and counts roughly 5 minutes, jumps to a sensor check loop, and then jumps back to the listen loop? I am hoping to run this on solar power so low power consumption would be nice.
What I'd like to do with the command unit is request temp/door status, and open/close door manually. Maybe also have a "disco mode" button that lights it up with RGB LED's just for kicks :D. Kind of like the electric tree in the Lorax movie. Hopefully after I get some feedback I'll be able to post some code for critique.
Anyway, I would really appreciate any comments or observations you all might have. When this is done and there's a tutorial for it, make sure I don't miss any of you in the credits XD. Thanks!