grove nfc_tag sample program

Dependencies:   mbed

Committer:
superphil06
Date:
Fri Mar 31 11:20:13 2017 +0000
Revision:
1:c492babe8dc3
Parent:
0:b939441bcdc7
grove nfc tag example programm

Who changed what in which revision?

UserRevisionLine numberNew contents of line
superphil06 0:b939441bcdc7 1 #include "mbed.h"
superphil06 1:c492babe8dc3 2 #include "nfc_tag.h"
superphil06 0:b939441bcdc7 3
superphil06 1:c492babe8dc3 4 #define NFC_ADRESS 0x53
superphil06 1:c492babe8dc3 5 //rx2 tx2
superphil06 1:c492babe8dc3 6 NfcTag nfcTag_cons(p28,p27,NFC_ADRESS<<1,USER_MODE);
superphil06 1:c492babe8dc3 7 bool flag = false;
superphil06 1:c492babe8dc3 8 bool preFlag = false;
superphil06 0:b939441bcdc7 9
superphil06 1:c492babe8dc3 10 int main()
superphil06 1:c492babe8dc3 11 {
superphil06 1:c492babe8dc3 12 //nfcTag = NfcTag(p15,p14);
superphil06 1:c492babe8dc3 13 while(true) {
superphil06 1:c492babe8dc3 14 printf("*****");
superphil06 1:c492babe8dc3 15 flag = nfcTag_cons.readuint8_t(EEPROM_I2C_LENGTH-1) == 0xff?true:false;// read 0x07ff block address
superphil06 1:c492babe8dc3 16 printf(" %x ",nfcTag_cons.readuint8_t(EEPROM_I2C_LENGTH-1));
superphil06 1:c492babe8dc3 17 if(flag != preFlag) {
superphil06 1:c492babe8dc3 18 printf("get remote NFC control signal!");
superphil06 1:c492babe8dc3 19 if(flag == true) {
superphil06 1:c492babe8dc3 20 printf("led will light up!");
superphil06 1:c492babe8dc3 21 } else {
superphil06 1:c492babe8dc3 22 printf("led will turn dark!");
superphil06 1:c492babe8dc3 23 }
superphil06 1:c492babe8dc3 24 preFlag = flag;
superphil06 1:c492babe8dc3 25 }
superphil06 1:c492babe8dc3 26 wait(1);
superphil06 0:b939441bcdc7 27 }
superphil06 1:c492babe8dc3 28 }