Grove - NFC Tag
Innehåll
Kompatibilitet
- Arduino
Port
- I2C
Bibliotek
https://github.com/Seeed-Studio/NFC_Tag_M24LR6E
NFC Reader for Android
https://github.com/Seeed-Studio/NFC_Tag_M24LR6E/blob/master/Resources/NfcVreader.apk
Exempelkod
Arduino
#include "NfcTag.h"
#include <Wire.h>
NfcTag nfcTag;
int led = 5;
bool flag = false;
bool preFlag = false;
void setup(){
Serial.begin(9600);
pinMode(led,OUTPUT);
nfcTag.init();
}
void loop(){
flag = nfcTag.readByte(EEPROM_I2C_LENGTH-1) == 0xff?true:false;
if(flag != preFlag){
Serial.println("get remote NFC control signal!");
if(flag == true){
Serial.println("led will light up!");
digitalWrite(led,HIGH);
}else{
Serial.println("led will turn dark!");
digitalWrite(led,LOW);
}
preFlag = flag;
}
delay(5*1000);
}