time.h counting hours for garduino


hi all!

first off, trying help. im newbie go easy ;)

im trying build garduino , using new time.h library.
what want do:

the plant light little pepper mint plants connected relay thats hooked , working.

every day, @ 10pm, want light go on , stay on 16 hours.
then off 8. same thing again, next day.

i want able track amount of hours plants subject light in form of simple integer able display on lcd screen. perhaps days nice too.

i stumped here, not start.

thanks lot! :-/

quote
i stumped here, not start.


here's 1 way how break task small , manageable task can start pretty 0 finished product. how long steps take depends on you, easier, require more work. should resolved problem of not knowing start.

step 1: write program blinks led without using function delay(). you'll find in tutorials using millis().

step 2: modify program step 1 blink 16 hour on, 8 hours off. hint: 8 hours 8*3600*1000 = 28800000 milliseconds, 16 hours twice much.

you have basic light control , work long started arduino @ beginning of correct phase. main problems is, happens if arduino loses power , restarts? doesn't know it's 10pm.

step 3: add counter illumination time. count minutes power on. format nicely , send out every minute on serial port.

step 4: here new hardware: add lcd display , display text sent out on serial port in step 3. add other nice information make display interesting example how long until light goes on or off again. additional information can done in step 3 too.

step 5: more new hardware, replace driving of led switching light on , off. guess want sort of relay plus necessary driving circuity. can find tutorial how properly.  

now have useful controls light , gives display on what's going on. last big problem solve happens when arduino loses power.

step 6: more hardware retrieve or keep current time. here place @ time library, comes bundles ds1307rtc library. using ds1307 real time clock , cheap solution (you can such modules vendors sparkfun). depending on are, might have other alternatives available such dcf77 receiver, gps signals or others. should have enough experience integrate module existing library. play around new module in separate sketch until can retrieve correct time.

step 7: apply learned in step 6 program step 5 time read via time library now() instead of millis(). 1 consequence you'll calculations of illumination time in seconds instead of in milliseconds, 8 hours 28800 , not 28800000.

now controller finished. waht want. last drawback only, on power loss, total illumination time lost. little more programming comes with:

step 8: update current illumination total every hour eeprom. don't update eeprom time, takes limited amount of writing before dies. on startup of arduino read value continue counting there. add button allow reset counter situation when start new batch of plants. @ point, able read arduino documentation on own find eeprom library or tutorial how read button.

step 9: build nice enclosure lighting controller.

step 10: use , have fun eating, snorting or smoking plants.

that's there is. if encounter problems @ step, it'll easier here, because able ask specific questions concrete problems , questions best , quickest answers. , please, make sure did previous steps before asking questions later one. of steps have increase in complexity should experience before attempting 1 of later ones.

korman


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > time.h counting hours for garduino


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums