const byte pinBut = A1;
byte butLst;

//GERRY MOD
//enum { None, SingleClick, DoubleClick };
enum { None, SingleClick, DoubleClick, YesSingle};

// -----------------------------------------------------------------------------
int
chkButton (void)
{
  const  unsigned long ButTimeout  = 250;
  static unsigned long msecLst;
  unsigned long msec = millis ();
  //GERRY MOD
  const int debDuration = 100;
  static unsigned long  debStartTime = 0;

  if (msecLst && (msec - msecLst) > ButTimeout)  {
    msecLst = 0;
	//GERRY MOD
    //return SingleClick;	
    return YesSingle;
  }

  byte but = digitalRead (pinBut);
  if (butLst != but)  {
    //GERRY MOD
    if (millis() - debStartTime < debDuration) {
      return None;
    }
    debStartTime = millis();
	
    butLst = but;

    if (LOW == but)  {   // press
      if (msecLst)  { // 2nd press
        msecLst = 0;
        return DoubleClick;
      }
      else {
        msecLst = 0 == msec ? 1 : msec;
		//GERRY MOD
        return SingleClick; //SINGLE?
      }
    }
  }

  return None;
}

// -----------------------------------------------------------------------------
void
loop ()
{

  switch (chkButton ())  {
    case SingleClick:
      Serial.println ("single?");
      break;

    case DoubleClick:
      Serial.println ("Its double");
      break;

    //GERRY MOD
    case YesSingle:
      Serial.println ("YesSingle");
      break;

  }
}

// -----------------------------------------------------------------------------
void
setup ()
{
  Serial.begin (9600);

  pinMode (pinBut, INPUT_PULLUP);
  butLst = digitalRead (pinBut);
}