 
 // Main routines, find header, then sync in with it, get a packet, and decode data in it, plus report any errors.
 void loop(){
-  tempBit=polarity; //these begin the same for a packet
+  tempBit=polarity^1; //these begin as opposites for each packet
   noErrors=true;
   firstZero=false;
   headerHits=0;

  Serial.begin(115200);//make it fast so it dumps quick!
  pinMode(RxPin, INPUT);
  pinMode(ledPin, OUTPUT);
  Serial.println();
  lDelay=2*sDelay;//just to make sure the 1:2 ratio is established. They can have some other ratio if required
  Serial.print("Using a delay of 1/4 bitWaveform ");// +-15% and they still seem to work ok, pretty tolerant!
  Serial.print(sDelay,DEC);

int ledPin          = 13;  //The number of the onboard LED pin

// Variables for Manchester Receiver Logic:
word    sDelay     = 240;  //Small Delay about 1/4 of bit duration try like 220 to 480
word    lDelay     = 480;  //Long Delay about 1/2 of bit duration  try like 440 to 880, 1/4 + 1/2 = 3/4
byte    polarity   = 1;    //0 for lo->hi==1 or 1 for hi->lo==1 for Polarity, sets tempBit at start
byte    tempBit       ;    //Reflects the required transition polarity
byte    bitState      ;    //State of the RxPin 3/4 way through Bit Waveform
byte    discards   = 0;    //how many leading "bits" need to be dumped, usually just a zero if anything eg discards=1
boolean firstZero  = false;//has it processed the first zero yet?  This a "sync" bit.
boolean noErrors   = true; //flags if signal does not follow Manchester conventions
//variables for Header detection
byte    headerBits = 10;   //The number of ones expected to make a valid header
byte    headerHits = 0;    //Counts the number of "1"s to determine a header
//Variables for Byte storage
byte    dataByte   = 0;    //Accumulates the bit information
byte    nosBits    = 0;    //Counts to 8 bits within a dataByte
byte    maxBytes   = 6;    //Set the bytes collected after each header. NB if set too high, any end noise will cause an error
byte    nosBytes   = 0;    //Counter stays within 0 -> maxBytes
//Variables for multiple packets
byte    bank       = 0;    //Points to the array of 0 to 3 banks of results from up to 4 last data downloads 
