grove nfc_tag sample program

Dependencies:   mbed

main.cpp

Committer:
superphil06
Date:
2017-03-31
Revision:
1:c492babe8dc3
Parent:
0:b939441bcdc7

File content as of revision 1:c492babe8dc3:

#include "mbed.h"
#include "nfc_tag.h"

#define NFC_ADRESS 0x53
//rx2 tx2
NfcTag nfcTag_cons(p28,p27,NFC_ADRESS<<1,USER_MODE);
bool flag = false;
bool preFlag = false;

int main()
{
    //nfcTag = NfcTag(p15,p14);
    while(true) {
        printf("*****");
        flag = nfcTag_cons.readuint8_t(EEPROM_I2C_LENGTH-1) == 0xff?true:false;// read 0x07ff block address
        printf(" %x ",nfcTag_cons.readuint8_t(EEPROM_I2C_LENGTH-1));
        if(flag != preFlag) {
            printf("get remote NFC control signal!");
            if(flag == true) {
                printf("led will light up!");
            } else {
                printf("led will turn dark!");
            }
            preFlag = flag;
        }
        wait(1);
    }
}