 	digitalWrite(pinButtonSwitch, HIGH);
 	digitalWrite(pinReedSwitch, HIGH);
 	Ethernet.begin(mac, ip);
+
+        pinMode(8, OUTPUT);
+        digitalWrite(8, LOW);
 }
 
 

		Serial.print("VALID\n");
	#endif
	if(isCardAuthorized()){
		tone(pinPiezo, toneAccepted, toneDuration);
		unlockDoor();
		cleanBuffer();
		reportOpened();
		return;
	}else{
		tone(pinPiezo, toneRejected, toneDuration);
	}
}


	return index%(BUFSIZE);
}

//called by Arduino framework when there are available bytes in input buffer
void serialEvent(){
        digitalWrite(8, HIGH);
	while (Serial.available())
        {
                char temp = Serial.read();
                if(cyclicBufferPosition < 10){
		  buffer[cyclicBufferPosition++] = temp;
                }else{
                  Serial.flush();
                }
		
	}
	lastSerialEventTime = millis();
        eventReceived = true;
        digitalWrite(8, LOW);
}

inline void cleanBuffer(){
