Any suggestions how to organize this?


i'm embarrassed admit i'm building yet chicken coop automation project. first project involves multiple inputs outputs. far i've flashed led's, faded rgb led's, controlled servos, run oled screen demos , stuff that.

just wondering how should structure this. have bits , pieces of code, i'm not sure best way organize be.  here basic blocks:

nrf24 listen/transmit (another arduino in house request info , send commands one)
 
check ldr // there 2 ldr's north/south divider between them, equal values indicates noon
         if sun on head , door closed, open it, toggle dooropen boolean, transmit door has been opened notification command unit // don't let them free range until around noon otherwise lay eggs on yard
        else  if no sunlight present , door open true, close it, toggle door open boolean, transmit door has been closed notification command unit
           
check temp/humidity sensor
           if temp > 70, run fan
           else if temp < 0, turn on heat lamp (they fine @ -30 winter 0 degrees 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 now)

my question multiple loops advantageous here? it's going listening rf unit of time, , checking sensors maybe every 5 minutes.
could have main loop listens , counts 5 minutes, jumps sensor check loop, , jumps listen loop? hoping run on solar power low power consumption nice.

what i'd command unit request temp/door status, , open/close door manually. maybe have "disco mode" button lights rgb led's kicks  :d. kind of electric tree in lorax movie. after feedback i'll able post code critique.

anyway, appreciate comments or observations might have. when done , there's tutorial it, make sure don't miss of in credits  xd. thanks!

if need multiple timings, use millis() instead of delay().
there famous example that: http://arduino.cc/en/tutorial/blinkwithoutdelay

are using nrf24l01+ ?
with library ? http://www.airspayce.com/mikem/arduino/nrf24/

i make functions sensors. inside functions possible averaging or debouncing.
in main loop() function collect information, , act upon that.

it possible check sensors every 5 minutes. can use millis() that, see if 5 minutes have passed. simple solution.
it possible continuously check sensors, , remember when door openend or closed using millis(). can prevent door being opened , closed every second. needs more programming skills has more possibilities. data of sensors available , program decides do.

i have sketch millis() create 'tick' every second. can things every second. have software counter count 60, can things every minute. , inside counter every hour , inside every day (some things need updated once day). schedular running background task. important things, webserver , communications continuously tested in loop() function without delay. testing millis() second 'tick' 1 of things in loop().


Arduino Forum > Using Arduino > Programming Questions > Any suggestions how to organize this?


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support