I guess you'd probably want to write a function for toggling the AC and keeping track of if the AC is on or not, something like :
unsigned char AC_ON = 0; /* Assume AC is off when car is started */
void toggle_AC() {
/* Never used an arduino so you'll have to substitute the real commands here /*
switch_on_relay();
wait_half_a_second_or_so();
switch_off_relay();
AC_ON = ~AC_ON; /* This toggles the value of AC_ON */
}Then in your main() function, call the toggle function whenever you have to change the state of the AC, eg :
if (AC_ON && celsius < 35){ // AC is on and car is too cold
toggle_AC(); // Turn AC off
}
else if (!AC_ON && celcius > 35) { // AC is off and car is too warm
toggle_AC(); // Turn AC on
}The problem with this approach is that if someone hits the AC switch the arduino will get confused.