 long pirReset = 3000; // How long to ignore further detects.
 long lastPirUp = 0;
 long lastPirDown = 0;
+
+boolean pulse = false;
+
 
 // Store the pir states on interupt.
 volatile byte flags = 0;

void setup()
{
    pinMode(DEBUG_LED_TX, OUTPUT);
    
    pinMode(PIR_UP_PIN, INPUT);
    pinMode(PIR_DOWN_PIN, INPUT);
    

  if (currentMillis - previousMillis > interval) {
    previousMillis = currentMillis;
    // TODO: reset previousMillis when overruns max value.
    
    pulse = !pulse;
    digitalWrite(DEBUG_LED_PULSE, pulse);
    

    // Can't set use millis in the interupt.
    if (bitRead(flags, F_UP_STAT)) {
      lastPirUp = currentMillis;
      //Serial.println("UP on");
      bitClear(flags, F_UP_STAT);
      digitalWrite(DEBUG_LED_MOTION, HIGH);
    }
    
    if (bitRead(flags, F_DOWN_STAT)) {
      lastPirDown = currentMillis;
      //Serial.println("DOWN on");
      bitClear(flags, F_DOWN_STAT);
      digitalWrite(DEBUG_LED_MOTION, HIGH);
    }

    
    if (bitRead(flags, F_UP) && currentMillis - lastPirUp > pirReset) {
      bitClear(flags, F_UP);
      //Serial.println("UP off");
      digitalWrite(DEBUG_LED_MOTION, LOW);
    }
      
    if (bitRead(flags, F_DOWN) && currentMillis - lastPirDown > pirReset) {
      bitClear(flags, F_DOWN);
      //Serial.println("DOWN off"); 
      digitalWrite(DEBUG_LED_MOTION, LOW);
    }
      
    if (bitRead(flags, F_UP) || bitRead(flags, F_DOWN) || pulse) { 
      char buf[50];
      sprintf(buf, "count=%lu,flags=%u", count, flags); 
   
