 			reset_seq();
 		}
 	}
+	else {reset_seq();}
 	Serial.print(seq_pos);
 	Serial.print(" ");
 	Serial.print(seq_sub);

	pinMode(PIN_INPUT, INPUT);
	digitalWrite(PIN_INPUT, PIN_DEFAULT);
	seq_pos = 0;
	seq_sub = 0;
}

void loop () 
{
	while (digitalRead(PIN_INPUT)==PIN_DEFAULT);
	lasthit = millis();
	while (digitalRead(PIN_INPUT)==PIN_ON);
	thisgap = millis() - lasthit;

	if (seq_pos==0 && seq_sub==0)
		smallgap = thisgap;
	Serial.print(thisgap);
	Serial.print(" ");
	Serial.println(smallgap);
	if (selisih(thisgap, smallgap)<TOLERANCE)
	{
		//-- small gap, expecting seq_sub complete
		if (seq_sub<seq[seq_pos])


void reset_seq()
{
	seq_sub = 1; seq_pos = 0; 
}

void setup() {
