Ajout ouverture forcé par l'utilisateur (switch sur pin 6)

Ajout signal sur LED pour bonne ou mauvaise ajout/suppression de tagRFID dans l'EEPROM
This commit is contained in:
Pierrick C 2017-09-24 19:48:55 +02:00
parent e612150f01
commit f166e3571d

View File

@ -12,6 +12,7 @@
#define RFID_TX 3
#define PROG_BUTTON 4
#define SERVO_CTRL 5
#define DOOR_BUTTON 6
// Others parameters
#define SERVO_SPEED 2
@ -277,11 +278,22 @@ void addNewTag(byte tag[14]) {
int tmp = findtag(tag);
if (tmp != -1 and tmp == tagnb) {
Serial.println("OK");
for (int i=0; i<3; i++) {
digitalWrite(GREEN_LED, HIGH);
delay(500);
digitalWrite(GREEN_LED, LOW);
delay(500);
}
}
else {
Serial.println("Failed");
for (int i=0; i<5; i++) {
digitalWrite(RED_LED, HIGH);
delay(500);
digitalWrite(RED_LED, LOW);
delay(500);
}
}
}
void delTag(byte tag[14]) {
@ -303,9 +315,19 @@ void delTag(byte tag[14]) {
int tmptag = readeepromtag(tagnb);
if (comparetag(tmptag, emptytag)) {
Serial.println("OK");
digitalWrite(GREEN_LED, HIGH);
delay(500);
digitalWrite(GREEN_LED, LOW);
delay(500);
}
else {
Serial.println("Failed");
for (int i=0; i<5; i++) {
digitalWrite(RED_LED, HIGH);
delay(500);
digitalWrite(RED_LED, LOW);
delay(500);
}
}
}
@ -326,6 +348,7 @@ void setup() {
//Mode for button and end-stop
pinMode(PROG_BUTTON, INPUT_PULLUP);
pinMode(DOOR_BUTTON, INPUT_PULLUP);
Serial.print(F("EEPROM length : "));
Serial.print(EEPROM.length());
@ -340,10 +363,15 @@ void setup() {
void loop() {
tag_ok = -1;
if (RFID.available() > 0 and !door_state ) readRFID();
if (RFID.available() > 0 and !door_state ) {
readRFID();
}
if (!digitalRead(DOOR_BUTTON)) {
Serial.println("Ouverture par l'utilisateur.");
door_state = 1;
}
updateDoor();
updateRedLED();
delay(10);