From 6fbb763d9caea6fe74298c84a9e441cdedf59269 Mon Sep 17 00:00:00 2001 From: Pierrick C Date: Sun, 26 Nov 2017 21:26:39 +0100 Subject: [PATCH] =?UTF-8?q?D=C3=A9sactivation=20UART=20avec=20le=20lecteur?= =?UTF-8?q?=20RFID=20quand=20porte=20non-ferm=C3=A9e+immobile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cat_on_diet_feeder/cat_on_diet_feeder.ino | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) 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();