Created
November 6, 2014 12:44
-
-
Save rogeriochaves/a778b13a42cf2fd18003 to your computer and use it in GitHub Desktop.
Using Arduino Elechouse's NFC to create vCard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if 0 | |
#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() { | |
Serial.begin(9600); | |
Serial.println("NDEF Writer"); | |
nfc.begin(); | |
} | |
void loop() { | |
Serial.println("\nPlace a formatted Mifare Classic NFC tag on the reader."); | |
if (nfc.tagPresent()) { | |
NdefMessage message = NdefMessage(); | |
message.addMimeMediaRecord("text/vcard", "BEGIN:VCARD\nVERSION:4.0\nFN:Oseias Arnaldo\nORG:React\nPHOTO;MEDIATYPE=image/png:http://react.ag/logo.png\nTEL;TYPE=work,voice;VALUE=uri:33432779\nEMAIL:oseia@react.ag\nREV:20080424T195243Z\nEND:VCARD"); | |
bool success = nfc.write(message); | |
if (success) { | |
Serial.println("Success. Try reading this tag with your phone."); | |
} else { | |
Serial.println("Write failed."); | |
} | |
delay(1000); | |
digitalWrite(13, LOW); | |
} | |
delay(200); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instead of printing lots of business cards, you can lend over your NFC Card with vCard data