Sommaire |
c'est dans cette partie que vous décrivez votre projet
#include <Wire.h> #include <Adafruit_NFCShield_I2C.h> #define IRQ (2) #define RESET (3) // Not connected by default on the NFC Shield Adafruit_NFCShield_I2C nfc(IRQ, RESET); int ledR = 9; int ledP = 10; int ledG = 11; int ledB = 12; uint8_t comp01[] = { 203,102,125,189,0,0,0 }; uint8_t comp02[] = { 77,243,159,35,0,0,0 }; uint8_t comp03[] = { 45,187,161,35,0,0,0 }; //*****************Init des variables du MicroP**************************** void setup(void) { Serial.begin(115200); Serial.println("Hello!"); pinMode(ledP, OUTPUT); pinMode(ledR, OUTPUT); pinMode(ledG, OUTPUT); pinMode(ledB, OUTPUT); digitalWrite(ledR,HIGH); digitalWrite(ledB,HIGH); digitalWrite(ledG,HIGH); digitalWrite(ledP,HIGH); nfc.begin(); uint32_t versiondata = nfc.getFirmwareVersion(); if (! versiondata) { Serial.print("Didn't find PN53x board"); while (1); // halt } // Got ok data, print it out! Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC); // Set the max number of retry attempts to read from a card // This prevents us from waiting forever for a card, which is // the default behaviour of the PN532. nfc.setPassiveActivationRetries(0xFF); // configure board to read RFID tags nfc.SAMConfig(); Serial.println("Waiting for an ISO14443A card"); } //***********************************Boucle MAIN *************************** void loop(void) { int count = 0; boolean success; uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type) // Wait for an ISO14443A type cards (Mifare, etc.). When one is found // 'uid' will be populated with the UID, and uidLength will indicate // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight) success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength); if (success) { Serial.println("Found a card!"); Serial.print("UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes"); //*******************Affichage INFO Carte***************************** Serial.print("UID Value: "); for (uint8_t i=0; i < uidLength; i++) { Serial.print(" ");Serial.print(uid[i], DEC); } Serial.println(""); Serial.print("UID Value: "); for (uint8_t i=0; i < uidLength; i++) { Serial.print(" ");Serial.print(uid[i], HEX); } //******************Comparaison Clé valide1************************** for (uint8_t i=0; i < uidLength; i++) { if (uid[i]==comp01[i]){ count=count + 1; } } if (count==uidLength){ digitalWrite(ledR, LOW); digitalWrite(ledG, HIGH); digitalWrite(ledB, HIGH); } //*********************Comparaison Clé valide2************************* count=0; for (uint8_t i=0; i < uidLength; i++) { if (uid[i]==comp02[i]){ count=count + 1; } } if (count==uidLength){ digitalWrite(ledR, HIGH); digitalWrite(ledG, HIGH); digitalWrite(ledB, LOW); } //*********************Comparaison Clé valide3************************* count=0; for (uint8_t i=0; i < uidLength; i++) { if (uid[i]==comp03[i]){ count=count + 1; } } if (count==uidLength){ digitalWrite(ledR, HIGH); digitalWrite(ledG, LOW); digitalWrite(ledB, HIGH); } //****************************Carte Magnetique Imcompatible***************** } else { // PN532 probably timed out waiting for a card Serial.println("Timed out waiting for a card"); } delay(1500); //regle la durée entre deux detection de cartes }
chercher ici : http://wikidebrouillard.org/index.php/Catégorie:Arduino
quelles peuvent être les applications technologique de ce montage, ou est-ce qu'on retrouve des programme qui y ressemble ?
© Graphisme : Les Petits Débrouillards Grand Ouest (Patrice Guinche - Jessica Romero) | Développement web : Libre Informatique