Do a search for "arduino program hysteresis". There are numerous examples that can be converted to temperature control.