Un ├ęchange d'information autour de la carte KeyDuino
 
HomeHome  FAQFAQ  RegisterRegister  Log inLog in  

Share | 
 

 NFC drawer lock

View previous topic View next topic Go down 
AuthorMessage
MrStein
KeyDuino TEAM
avatar

Messages : 59
Reputation : 3
Date d'inscription : 2015-10-10
Age : 23
Localisation : Lille, FRANCE

PostSubject: NFC drawer lock   Sat 10 Oct - 16:45


Code:

/*********************************
 Code by Pierre CHARLIER (mrstein@hotmail.fr)
 Please remplace the "xxxxxxxxxx" by your tag ID.
 You will need KeyDuino library to use it.
 ***********************************/


#include "KeyDuino.h"
KeyDuino keyDuino;

 #define GACHE 12
 #define LED 13

//definition des clefs
String CLEF1 = "xxxxxxxxxx";
String CLEF2 = "xxxxxxxxxx";
String CLEF3 = "xxxxxxxxxx";



//*******************Tag READ fonction
String fct_lecture() {
  String Received;
  boolean success;
  uint8_t IdReceived[] = { 0, 0, 0, 0, 0, 0, 0 };
  uint8_t Id_Length;

  if (success = keyDuino.readPassiveTargetID(PN532_MIFARE_ISO14443A, &IdReceived[0], &Id_Length)) {
    for (uint8_t i = 0; i < Id_Length; i++)
      Received += String(IdReceived[i], HEX);
    Serial.println(Received);
    return (Received);
  }
  else
    return ("NULL");
}




void setup(void) {
  Serial.begin(115200);
  keyDuino.begin();
  pinMode(GACHE, OUTPUT);
  pinMode(LED, OUTPUT);
  digitalWrite(LED, HIGH);
  Serial.println("NFC LOCK");
}



void loop(void) {
  String Received;
  Received = fct_lecture();
  if ((Received == CLEF1 || Received == CLEF2  || Received == CLEF3)) {
    Serial.println("STATE: OPEN");
    digitalWrite(GACHE, HIGH);
    delay(2000);
    Serial.println("STATE: CLOSE");
    digitalWrite(GACHE, LOW);
  }

  else {
    if (Received != 0) {
      Serial.println("Key not found");
keyDuino.buzz(20);
    }
  }
}

Back to top Go down
http://keyduino.forumsactifs.com
 
NFC drawer lock
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Line Lock Info needed
» Trunk lock relocation / Shaved trunk lid
» Blue coat Lock up
» (2) oem impala SS trunk lock emblems
» Silent Swordsman Lock Deck (New Banlist Edited)

Permissions in this forum:You cannot reply to topics in this forum
KeyDuino forum :: KeyDuino projects & tutorial :: Tutorials :: Official tutorial-
Jump to: