Go Down

Topic: Salt Reef seasons IF Then Confusion!? (Read 2 times) previous topic - next topic

djjester611

How about a switch case statement,  if(months&&date) good switch

Case1 spring

Nick Gammon

Something like:

Code: [Select]

 switch (month)
   {
   case 1:   // January
   case 2:   // and February
       season = summer;
       break;

   case 3:    // March
       if (day >= 21)
         season = autumn;
       else
         season = summer;
       break;

// ... and so on
   } // end of switch


I live in the southern hemisphere BTW, which is why it is autumn right now.

cjdelphi

one thing about me is (and people may come to notice...) i really hate to over-complicate ANYTHING eg if it's not needed or an alternative is there take it anything reduce your memory usage or binary size.

but, and my understanding could be way off here.. but.. am I right in understanding you want  certain actions depending on the time of year? eg if it's summer more daylight therefor the the lights come on at different times of the day, so the RTC is read and through a series of calculations you know exactly when to switch on and off the lights and other things like pumps and stuff.

if so?.. why an RTC at all?

run a cable (or invest in another small arduino with 2 wireless modules) to a window and on the end of the cable attach a photo resistor, feed the other end into your analogue in and read the values appropriately, or use another arduino to relay back the information if you want a clean setup... now when it "goes dark" or cloudy or a storm approaches and it's dark at 3pm, you don't need to guess what's going on, you actually have real world data coming in, based on how much light there is, you switch the lights on or off.

Now having said all that i could be completely wrong and you have to use the RTC and you can't use say a Temperature Sensor and Light Sensor to fully automate it.. imagine if street lamps only came on at a certain times based on the year date and time, no to consistently get it come on as it goes dark be the middle of the day or night time, a light sensor is used. 


Nick Gammon

Yes, good idea.

Another approach would be to take the date, turn it into a Julian date (ie. day of year) ... I think there are quite a few short algorithms for that. Then simply do a straight compare. There will only be 4 break points then.

And here's another idea ... by reading in sunlight you can deduce the season. For example, very short days ... winter.

cjdelphi


Yes, good idea.

Another approach would be to take the date, turn it into a Julian date (ie. day of year) ... I think there are quite a few short algorithms for that. Then simply do a straight compare. There will only be 4 break points then.

And here's another idea ... by reading in sunlight you can deduce the season. For example, very short days ... winter.


yeah, store how much light comes in and at the end of the day store it onto the eeprom, to get number hours of light, like it, very short days = nuclear winter (or just plain old winter) :D

Go Up