added arduino nfcReader files (#42)

This commit is contained in:
Valentin Heiserer
2024-04-18 00:49:50 +02:00
committed by GitHub
parent 76cb0eaf1a
commit 6259d0bef3
68 changed files with 8463 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
#include <Wire.h>
#include <Adafruit_PN532.h>
#define SDA_PIN 2
#define SCL_PIN 1
Adafruit_PN532 nfc(SDA_PIN, SCL_PIN);
void setup(void) {
Serial.begin(115200);
nfc.begin();
uint32_t versiondata = nfc.getFirmwareVersion();
if (!versiondata) {
Serial.print("Didn't find PN53x board");
while (1);
}
nfc.SAMConfig();
}
void loop(void) {
uint8_t success;
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };
uint8_t uidLength;
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
if (success) {
for (uint8_t i = 0; i < uidLength; i++) {
String hexString = (uid[i] < 0x10 ? "0" : "") + String(uid[i], HEX);
hexString.toUpperCase();
Serial.print(hexString);
}
Serial.println("");
delay(1000);
}
}