Skip to content

Instantly share code, notes, and snippets.

@arduinothai
Created May 8, 2018 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arduinothai/5c253e14ff6b92b740d741a0ac17b9ec to your computer and use it in GitHub Desktop.
Save arduinothai/5c253e14ff6b92b740d741a0ac17b9ec to your computer and use it in GitHub Desktop.
#if 0 // 1 คือใช้งานแบบ SPI
#include <SPI.h>
#include <PN532_SPI.h>
#include <PN532.h>
#include <NfcAdapter.h>
PN532_SPI pn532spi(SPI, 10);
NfcAdapter nfc = NfcAdapter(pn532spi);
#else
#include <Wire.h>
#include <PN532_I2C.h>
#include <PN532.h>
#include <NfcAdapter.h>
PN532_I2C pn532_i2c(Wire);
NfcAdapter nfc = NfcAdapter(pn532_i2c);
#endif
void setup(void) {
Serial.begin(9600);
Serial.println("NDEF Reader");
nfc.begin();
}
void loop(void) {
Serial.println("\nScan a NFC tag\n");
if (nfc.tagPresent())
{
NfcTag tag = nfc.read();
tag.print();
}
delay(5000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment