Listing 1. Sprinkler Algorithm

Sprinkler_Zone(day,time,duration)
{
  // initialize our system

  // begin our infinite loop to check time and date
  for(;;)
    {
      // get the date and time
      get_date_and_time(date,time);

      // inspect if the date and time are correct
      if(date and time matches)
        {
          // turn on valve
          // wait for watering duration
          // turn off valve
        }

      // sleep for a while
    }
}