the code:
/*********************************
You will need PN532_HSU.h & PN532.h library to use it.
***********************************/
#include < PN532_HSU.h > #include < PN532.h > #define BUZZER 15
PN532_HSU pn532hsu(Serial1);
PN532 nfc(pn532hsu);
String NFC_Key_1 = "xxxx";
String NFC_Key_2 = "xxxx";
String PASSWORD = "xxxxxxxx";
//*******************fonction lecture de tag
String fct_lecture() {
String Received;
boolean success;
uint8_t IdReceived[] = {
0, 0, 0, 0, 0, 0, 0
};
uint8_t Id_Length;
if (success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, & IdReceived[0], & Id_Length)) {
for (uint8_t i = 0; i < Id_Length; i++)
Received += String(IdReceived[i], HEX);
return (Received);
} else return ("NULL");
}
void setup(void) {
Serial.begin(115200);
Serial.println("Hello!");
nfc.begin();
uint32_t versiondata = nfc.getFirmwareVersion();
nfc.setPassiveActivationRetries(0xFF);
nfc.SAMConfig();
pinMode(BUZZER, OUTPUT);
}
void loop(void) {
String Received;
Received = fct_lecture();
if (Received != "NULL") {
Serial.print("NFC tag found: ");
Serial.println(Received);
if (Received == NFC_Key_1 || Received == NFC_Key_2) {
digitalWrite(BUZZER, HIGH);
delay(100);
digitalWrite(BUZZER, LOW);
Keyboard.println(PASSWORD);
delay(1000);
}
} else Serial.print(".");
}
EDIT BY JOHN, adding three ` before and after your code makes it a code block and does syntax highlighting :) Also I fixed your lazy indenting! :P