      delay(50); 
    }
       else {
-//        Serial.print("No Ack ");
         showString(PSTR("No Ack "));
         Serial.print(scan);
         showString(PSTR("\r"));
-//        Serial.print("\r");
         delay(50); 
       }
   }
   if ((upHigh == 0) || (upLow == 0xFFFF)) return;  // If nobody answers then restart loop
-//    Serial.print("Scan up complete "); 
     showString(PSTR("Scan up complete "));
     Serial.print(upLow);
-//    Serial.print("-");
     showString(PSTR("-"));
     Serial.println(upHigh);
     delay(100);
     downLow = 0xFFFF; 
     downHigh = 0;
-  for (scan = (frequency + 50); scan > (frequency - 50); --scan)
+  for (scan = (frequency_offset + 50); scan > (frequency_offset - 50); --scan)
   {
    rf12_control(0xA000 + scan); 
    byte good = probe();

     delay(50); 
   }
      else {
//        Serial.print("No Ack ");
        showString(PSTR("No Ack "));
        Serial.print(scan);
        showString(PSTR("\r"));
//        Serial.print("\r");
        delay(50); 
      }
  }
  if ((downHigh == 0) || (downLow == 0xFFFF)) return;  // If nobody answers then restart loop
  showString(PSTR("Scan down complete "));
//  Serial.print("Scan down complete "); 
  Serial.print(downLow);
//  Serial.print("-");
    showString(PSTR("-"));
  Serial.println(downHigh);

        
 frequency = ( ((upLow + downLow) / 2) + ((((upHigh + downHigh) / 2) - ((upLow + downLow)/ 2)) / 2)   );
// Serial.print("Centre frequency offset is ");
  showString(PSTR("Centre frequency offset is "));
  Serial.println(frequency);
  delay(50);
 config.ee_frequency_hi = frequency >> 8;
 config.ee_frequency_lo = frequency & 0x00FF;

  config.crc = ~0;
  for (byte i = 0; i < sizeof config - 2; ++i)

/// this sketch then enters a frequency scanning mode to find the
/// centre of frequency offset from its partner ack'ing Jeenode.
/// 2013-09-13 <john<AT>o-hare<DOT>net> http://opensource.org/licenses/mit-license.php


#define GROUP 212
#define NODE 9

#include <JeeLib.h>
#include <util/crc16.h>
