mirror of
https://github.com/Vale54321/schafkopf-bot.git
synced 2025-12-15 19:29:33 +01:00
added arduino nfcReader files (#42)
This commit is contained in:
committed by
GitHub
parent
76cb0eaf1a
commit
6259d0bef3
38
Arduino/nfcReader/nfcReader.ino
Normal file
38
Arduino/nfcReader/nfcReader.ino
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user