daily pastebin goal
32%
SHARE
TWEET

Untitled

a guest Mar 19th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Adafruit_PN532.h>
  2. #include <Wire.h>
  3.  
  4. #define SCK  (13)
  5. #define MISO (12)
  6. #define MOSI (11)
  7. #define SS   (10)
  8. Adafruit_PN532 nfc(SCK, MISO, MOSI, SS);
  9.  
  10. void setup()
  11. {  
  12.   Serial.begin(9600);
  13.   Serial.println("Initializing please wait.......");
  14.   delay(3000);
  15.   nfc.begin();
  16.  
  17.   uint32_t versiondata = nfc.getFirmwareVersion();
  18.   if (! versiondata)
  19.   {
  20.     Serial.print("Didn't find PN53x board");
  21.     while (1); // halt
  22.   }
  23.  
  24.   Serial.print("Device Found PN5 Chip");
  25.   Serial.println((versiondata>>24) & 0xFF, HEX);
  26.   Serial.print("Firmware version > ");
  27.   Serial.print((versiondata>>16) & 0xFF, DEC);
  28.   Serial.println((versiondata>>8) & 0xFF, DEC);
  29.   nfc.SAMConfig(); //Set to read RFID tags
  30.   Serial.println("Waiting for RFID Card ...");
  31. }
  32.      
  33. void loop()
  34. {
  35.   uint8_t success = 0;
  36.   uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };
  37.   uint8_t uidLength;
  38.   success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
  39.   if (success)
  40.   {
  41.       Serial.println("Card Detected!");
  42.   }
  43.   else
  44.   {
  45.       Serial.println("Card Not Detected or Removed!");
  46.   }
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top