    delay(100);
  }
  delay(100);
+}
+
+void blinkRedLed() {
+  digitalWrite(RED_LED, HIGH);
+  delay(200);
+  digitalWrite(RED_LED, LOW);
+  delay(200);
+  digitalWrite(RED_LED, HIGH);
+  delay(200);
+  digitalWrite(RED_LED, LOW);
+}
+
+void turnGreenLedOn() {
+  digitalWrite(GREEN_LED, HIGH);
+}
+
+void turnGreenLedOff() {
+  digitalWrite(GREEN_LED, LOW);
+}
+
+void openTurnstile() {
+  for(byte angle = 90; angle > 0; angle--)    
+  {                                
+    servo.write(angle);           
+    delay(5);       
+  } 
+
+}
+
+void closeTurnstile() {
+  for(byte angle = 0; angle < 90; angle++)  
+  {                                  
+    servo.write(angle);               
+    delay(5);                   
+  }  
 }
  byte buffer[EF_ID_SERVIZI_LENGTH];
  if (!cie.read_EF_ID_Servizi(buffer, &bufferLength)) {
    Serial.print(F("Error reading EF.ID_SERVIZI"));
    delay(1000);
    return;
  }
  Serial.print(F("EF.ID_Servizi: "));
  cie.printHex(buffer, bufferLength);

  printHi();
  count++;
  delay(1000);
  clearMatrix();
  delay(200);
  printId(buffer);
  delay(200);
  printCount();


  Serial.println();

  matrix.begin(0x70);
  count = 0;
  clearMatrix();

  pinMode(GREEN_LED, OUTPUT);
  pinMode(RED_LED, OUTPUT);

  digitalWrite(RED_LED, LOW);
  digitalWrite(GREEN_LED, LOW);

  servo.attach(SERVO); 

  Serial.println(F("PN532 initialized, waiting for a CIE card..."));
}

