buenzliai/main/main.ino

44 lines
857 B
Arduino
Raw Normal View History

2024-05-15 12:19:07 +00:00
#include <PN532.h>
#include <SPI.h>
2024-05-15 08:40:32 +00:00
2024-05-15 12:19:07 +00:00
#define PN532_CS 10
PN532 nfc(PN532_CS);
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup(void) {
nfc.begin();
uint32_t versiondata = nfc.getFirmwareVersion();
if (! versiondata) {
while (1); // halt
}
// configure board to read RFID tags and cards
nfc.SAMConfig();
2024-05-15 08:40:32 +00:00
}
2024-05-15 12:19:07 +00:00
void loop(void) {
uint32_t id;
// look for MiFare type cards
id = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A);
if (id != 0)
{
uint8_t keys[]= { 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF };
if(nfc.authenticateBlock(1, id ,0x08,KEY_A,keys)) //authenticate block 0x08
{
//if authentication successful
uint8_t block[16];
//read memory block 0x08
if(nfc.readMemoryBlock(1,0x08,block))
{
2024-05-15 08:40:32 +00:00
2024-05-15 12:19:07 +00:00
}
}
}
delay(1000);
2024-05-15 08:40:32 +00:00
}