Using temp sensor and RTC to control engine heater?

Hello everybody!

I´ve been playing around with an Arduino for a while, and doing the different examples supplied with the kit I bought.. Can´t really say that I´ve grasped the idea of programing yet, but copy/paste and some simple debugging has worked out ok .. I´ve been working with electric/electronic devices for 20 yrs, but my only real programming experience comes from BASIC (:D) attempts with an Apple IIc in the late 80-ies.

I want to make a project of "my own" and as winter time is approaching over here in Sweden, so is the time for engine and cabin heaters.. There are ready made solutions to buy, but since I have a few arduinos, temp sensor, RTC, and relays I thought that some simple wiring and programing could easily do the trick.

The question is, how do I go about the programming?

The program is meant to switch on the cabin/engine heater at different times, depending on outside temperature, the colder the earlier.

So, I preset a time that I leave every morning, and I want the relay to switch on four hours before if the temperature is less than -15 degrees celsius, three hours if it´s less than -10, two hours if it´s less than -5 and 1 hour if its between 0 - 10 degrees celsius.

I figure that there are two different ways to do it;

A: Check time. If its less than departure - 4 hrs, delay 60 sec. If time is within departure - 4 hrs, check temp. If temp is less than -15 switch relay on. If temp > -15 delay 1 hr. Check temp. If less than -10 switch relay on. If temp > -10 delay 1 hr. Etc.

B: Check temp, and depending on the temperature decide what to do.

Is there any other way to do it? I tried to google but I couldn't find any similar project idea to learn from...

Thanks in advance!

Maybe the code could look something like this;

byte timeToLeaveInHours( ) {
  // write a function to return a whole number of hours between 0 and 24
  // based on the current time and the standard time to leave the house
  //
}

loop() {

  if (
           ( outsideTemperature < -15 &&  timeToLeaveInHours( ) == 4 )
      ||   ( outsideTemperature < -10 &&  timeToLeaveInHours( ) == 3 )
      ||   ( outsideTemperature < -5  &&  timeToLeaveInHours( ) == 2 )
      ||   ( outsideTemperature <  10 &&  timeToLeaveInHours( ) == 1 )
   ) { SwitchHeaterOn() ; }

  else { SwitchHeaterOff() ; }

}

6v6gt:
Maybe the code could look something like this;

byte timeToLeaveInHours( ) {

// write a function to return a whole number of hours between 0 and 24
  // based on the current time and the standard time to leave the house
  //
}

loop() {

if (
          ( outsideTemperature < -15 &&  timeToLeaveInHours( ) == 4 )
      ||  ( outsideTemperature < -10 &&  timeToLeaveInHours( ) == 3 )
      ||  ( outsideTemperature < -5  &&  timeToLeaveInHours( ) == 2 )
      ||  ( outsideTemperature <  10 &&  timeToLeaveInHours( ) == 1 )
  ) { SwitchHeaterOn() ; }

else { SwitchHeaterOff() ; }

}

Thank you!