 }
 
 void loop(){  
-  return
   // La porte est ouverte
   if ( ! doorSwitch.ReadInput() )
   {
-    Serial.print("Elevator door opened. Closing...");
+    Serial.println("Elevator door opened. Closing...");
     // On la ferme et on attend
+    conveyor1.writeMicroseconds(CONVEYOR_STOP);
     digitalWrite(DOOR_PIN, HIGH);
     doorSwitch.WaitForPress();
     digitalWrite(DOOR_PIN, LOW);
-    Serial.print("Elevator door closed.");
+    Serial.println("Elevator door closed.");
   }
   else{
     // L'ascenseur n'est pas en haut

#include "LimitSwitch.h"

//////// Pins //////// 
#define ELEVATOR_SWITCH_PIN     46
#define DOOR_SWITCH_PIN         50
#define ELEVATOR_PIN            4
#define DOOR_PIN                5
#define CONVEYOR1_PIN           6
#define CONVEYOR2_PIN           7


      // Arreter le tapis sur l'ascenseur (au cas ou il roulerait...)
      conveyor2.writeMicroseconds(CONVEYOR_STOP);
      // On monte l'ascenseur et on attend
      Serial.println("Starting elevator.");
      conveyor1.writeMicroseconds(CONVEYOR_STOP);
      digitalWrite(ELEVATOR_PIN, HIGH);
      elevatorSwitch.WaitForPress();
      // Arreter l'ascenseur
      digitalWrite(ELEVATOR_PIN, LOW); 
      Serial.println("Stopping elevator.");
      delay(1000);
      conveyor1_running_until = millis();
    }
    else{
      // Si les deux switches sont appuyées, on roule les deux tapis avec un petit pattern sur le premier.
      if(conveyor1_running_until != 0 && conveyor1_running_until < millis())
      {
        Serial.println("Stop conveyor1");
        conveyor1_stopped_until = millis() + CONVEYOR1_STOPTIME;
        conveyor1_running_until = 0;
        conveyor1.writeMicroseconds(CONVEYOR_STOP);
      }
      else if(conveyor1_stopped_until != 0 && conveyor1_stopped_until < millis())
      {
        Serial.println("Start conveyor1");
        conveyor1_running_until = millis() + CONVEYOR1_RUNTIME;
        conveyor1_stopped_until = 0;
        conveyor1.writeMicroseconds(CONVEYOR_RUN);
      }
      conveyor2.writeMicroseconds(CONVEYOR_RUN);
    }
  }
