#include #include #include #include PN532_I2C pn532_i2c(Wire); NfcAdapter nfc = NfcAdapter(pn532_i2c); #define Content_Type "text/admin" String string2write = "myUsername"; #define LED_PIN 8 // pin for the LED boolean already_write = false; void setup() { Serial.begin(9600); // initialize serial communications nfc.begin(); // initialize NfcAdapter pinMode(LED_PIN, OUTPUT); // make the led pin an output digitalWrite(LED_PIN, HIGH); // set it low turn off the led Serial.println("Ready to write data to tag"); } void loop() { if (nfc.tagPresent() && !already_write) { // if there's a tag present digitalWrite(LED_PIN, LOW); // turn off the success light if on delay(100); digitalWrite(LED_PIN, HIGH); // turn off the success light if on NdefMessage message; // make a new NDEF message // add the input string as a record: message.addMimeMediaRecord(Content_Type, string2write); boolean success = nfc.write(message); // attempt to write to the tag if (success) { // let the desktop app know you succeeded: Serial.println("Result: tag written."); already_write = true; digitalWrite(LED_PIN, LOW); // turn off the success light if on } else { // let the desktop app know you failed: Serial.println("Result: failed to write to tag"); } } delay(1000); }