Listing 1. Basic Algorithm in C Pseudo-Code

for (;;) {
  // retrieve the sensor data
  read_inputs(&Key_ON, &temperature, &motion_detected);

  if (Key_ON) {
    // shut off alarms, wait
    silence_alarm();
  }
  else if (temperature > limit) {
    if (motion_detected) {
      // signal alarm, send an e-mail
      sound_alarm();
    }
  }
  // delay to avoid needlessly wasting CPU
  sleep(delay_interval);
}