diff --git a/code/cat_on_diet_feeder/cat_on_diet_feeder.ino b/code/cat_on_diet_feeder/cat_on_diet_feeder.ino index d111ee4..e74d74a 100644 --- a/code/cat_on_diet_feeder/cat_on_diet_feeder.ino +++ b/code/cat_on_diet_feeder/cat_on_diet_feeder.ino @@ -6,7 +6,7 @@ #include //Configuration -const float SERVO_SPEED = 0.8; +const float SERVO_SPEED = 1.8; const float OPEN_ANGLE = 10.0; const float CLOSED_ANGLE = 160.0; @@ -182,6 +182,20 @@ void disableServo() { } } +void updateSerial() { + //Désactive la connexion au lecteur RFID quand la + //trappe est en mouvement ou ouverte pour éviter les + // parasite + if (RFID and (door_state or door_move)) { + RFID.end(); + } + else { + //Active la connexion au lecteur RFID quand la + //trappe est fermée et immobile + RFID.begin(9600); + } +} + void updateDoor() { //Check if the need to move and move it @@ -411,10 +425,12 @@ void setup() { void loop() { tag_ok = -1; - if (!door_state and !door_move and RFID.available() > 0 ) { + //Lecture RFID + if (Serial and RFID.available() > 0 ) { readRFID(); } + //Ouverture manuelle if (!digitalRead(DOOR_BUTTON)) { Serial.println("Ouverture par l'utilisateur."); door_state = 1; @@ -433,7 +449,8 @@ void loop() { if (door_state and !door_move and catIsHere()) { door_timer = millis() + DOOR_OPENED_TIME; } - + + updateSerial(); updateDoor(); updateLED();