adds libararies and example code
This commit is contained in:
parent
0e8ad3a5db
commit
6541848330
3 changed files with 38 additions and 4 deletions
BIN
libraries/pn532_spi.zip
Normal file
BIN
libraries/pn532_spi.zip
Normal file
Binary file not shown.
BIN
libraries/vma211_spi.zip
Normal file
BIN
libraries/vma211_spi.zip
Normal file
Binary file not shown.
|
@ -1,9 +1,43 @@
|
||||||
void setup() {
|
#include <PN532.h>
|
||||||
// put your setup code here, to run once:
|
#include <SPI.h>
|
||||||
|
|
||||||
|
#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();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop(void) {
|
||||||
// put your main code here, to run repeatedly:
|
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))
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue