 
 unsigned long msgId = 0;        // Each transmission has an id so the receiver knows if it missed something.
 unsigned long lastTransmit = 0; // The last time a transmission was sent.
+char* msgQueue[MSG_QUEUE_LENGTH];
+unsigned long msgTime[MSG_QUEUE_LENGTH];
+byte msgTransmitted[MSG_QUEUE_LENGTH]; // Number of times the message has been transmitted.
 
 long powerTimeout = 60000;      // Time to wait in milliseconds to power down if no detection.
  

#define F_ACTIVE_LEFT   4 // 1 = detection  0 = no detection
#define F_ACTIVE_RIGHT  5 // 1 = detection  0 = no detection

const byte DISTANCE_THRESHOLD = 40; // Less than this (in cm) activates the detection sequence.

// Pins

  
  pinMode(PIN_DEBUG_MOTION, OUTPUT);
  
  // Init the message queue.
  for (uint8_t i = 0; i < MSG_QUEUE_LENGTH; i++) {
      char buf[MSG_BUFFER_LEN] = {0};
      msgQueue[i] = buf;
      msgTime[i] = 0;
      msgTransmitted[i] = 0;
  }
  
  vw_set_tx_pin(PIN_RF_TX);
  vw_setup(2000);      // Bits per sec
