 #define RESET 7
 
 // set up memory push buttons
-#define M1Sw 8
-#define M2Sw 9
+#define MEM_BUTTON_START_PIN  8  // digital pin where mem buttons start
+#define NUMBER_MEM_BUTTONS    2  // how many mem buttons
 
 const double bandStart = 100000;  // start of Gnerator at 100 KHZ
 const double bandEnd = 40000000; // End of Generator at 40 MHz --signal will be a bit flaky!

long lastBlink = 0;
boolean blinkState = false;

boolean m1armed = false;
boolean m2armed = false;
long lastM1 = 0;
long lastM2 = 0;

int eeAddressStart = 0;


  }
  
  // handle memory buttons
  for (int buttons = 0; buttons < NUMBER_MEM_BUTTONS; buttons++) {
    if(!mem_armed[buttons] && !digitalRead(MEM_BUTTON_START_PIN+buttons) && millis() - last_mem[buttons] > 50) {
      last_mem[buttons] = millis();
      mem_armed[buttons] = true;
    }
    if(mem_armed[buttons] && digitalRead(MEM_BUTTON_START_PIN+buttons) && millis() - last_mem[buttons] > 50) {  
      //pushed, but for how long?
      lcd.setCursor(0,1);
      if(millis() - last_mem[buttons] > 500) {
      // long push = commit to memory
      EEPROM.put(eeAddressStart+buttons*sizeof(double),freq);
      lcd.print("m");
      lcd.print(buttons);
      lcd.print(" stored");
      } else {
      // short push = qsy to memory frequency
      EEPROM.get(eeAddressStart+buttons*sizeof(double),freq);
      lcd.print("recall m");
      lcd.print(buttons);
      send_frequency(freq);     
      display_frequency(freq);
      }
      mem_armed[buttons] = false;
      last_mem[buttons] = millis();
    }
  }
  
  
}

// subroutine to display the frequency...
