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:
		@@ -12,6 +12,7 @@
 | 
				
			|||||||
#define RFID_TX     3
 | 
					#define RFID_TX     3
 | 
				
			||||||
#define PROG_BUTTON 4
 | 
					#define PROG_BUTTON 4
 | 
				
			||||||
#define SERVO_CTRL  5
 | 
					#define SERVO_CTRL  5
 | 
				
			||||||
 | 
					#define DOOR_BUTTON 6
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Others parameters
 | 
					// Others parameters
 | 
				
			||||||
#define SERVO_SPEED 2
 | 
					#define SERVO_SPEED 2
 | 
				
			||||||
@@ -277,11 +278,22 @@ void addNewTag(byte tag[14]) {
 | 
				
			|||||||
  int tmp = findtag(tag);
 | 
					  int tmp = findtag(tag);
 | 
				
			||||||
  if (tmp != -1 and tmp == tagnb) {
 | 
					  if (tmp != -1 and tmp == tagnb) {
 | 
				
			||||||
    Serial.println("OK");
 | 
					    Serial.println("OK");
 | 
				
			||||||
 | 
					    for (int i=0; i<3; i++) {
 | 
				
			||||||
 | 
					      digitalWrite(GREEN_LED, HIGH);
 | 
				
			||||||
 | 
					      delay(500);
 | 
				
			||||||
 | 
					      digitalWrite(GREEN_LED, LOW);
 | 
				
			||||||
 | 
					      delay(500);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else {
 | 
					  else {
 | 
				
			||||||
    Serial.println("Failed");
 | 
					    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]) {
 | 
					void delTag(byte tag[14]) {
 | 
				
			||||||
@@ -303,9 +315,19 @@ void delTag(byte tag[14]) {
 | 
				
			|||||||
  int tmptag = readeepromtag(tagnb);
 | 
					  int tmptag = readeepromtag(tagnb);
 | 
				
			||||||
  if (comparetag(tmptag, emptytag)) {
 | 
					  if (comparetag(tmptag, emptytag)) {
 | 
				
			||||||
    Serial.println("OK");
 | 
					    Serial.println("OK");
 | 
				
			||||||
 | 
					    digitalWrite(GREEN_LED, HIGH);
 | 
				
			||||||
 | 
					    delay(500);
 | 
				
			||||||
 | 
					    digitalWrite(GREEN_LED, LOW);
 | 
				
			||||||
 | 
					    delay(500);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else {
 | 
					  else {
 | 
				
			||||||
    Serial.println("Failed");
 | 
					    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
 | 
					  //Mode for button and end-stop
 | 
				
			||||||
  pinMode(PROG_BUTTON, INPUT_PULLUP);
 | 
					  pinMode(PROG_BUTTON, INPUT_PULLUP);
 | 
				
			||||||
 | 
					  pinMode(DOOR_BUTTON, INPUT_PULLUP);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Serial.print(F("EEPROM length : "));
 | 
					  Serial.print(F("EEPROM length : "));
 | 
				
			||||||
  Serial.print(EEPROM.length());
 | 
					  Serial.print(EEPROM.length());
 | 
				
			||||||
@@ -340,10 +363,15 @@ void setup() {
 | 
				
			|||||||
void loop() {
 | 
					void loop() {
 | 
				
			||||||
  tag_ok = -1;
 | 
					  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();
 | 
					  updateDoor();
 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  updateRedLED();
 | 
					  updateRedLED();
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  delay(10);
 | 
					  delay(10);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user