Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 #include "Adafruit_PN532.h " 00003 00004 #define SS PTD0 00005 // PTD1 is also LED_BLUE, it will blink during SPI communication. 00006 #define SCK PTD1 00007 #define MOSI PTD2 00008 #define MISO PTD3 00009 00010 Serial id(PTA2, PTA1); 00011 int previous = 0; 00012 00013 Adafruit_PN532 nfc(SCK, MISO, MOSI, SS); 00014 00015 void loop(void); 00016 00017 int main() { 00018 id.baud(9600); 00019 nfc.begin(); 00020 00021 uint32_t versiondata = nfc.getFirmwareVersion(); 00022 if (! versiondata) { 00023 while (1); // halt 00024 } 00025 00026 nfc.SAMConfig(); 00027 00028 while(1) { loop(); } 00029 } 00030 00031 00032 void loop(void) { 00033 uint8_t success; 00034 uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; 00035 uint8_t uidLength; 00036 00037 success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength); 00038 00039 if (success) { 00040 previous = 1; 00041 00042 if (uidLength == 4) 00043 { 00044 uint8_t tag_1 = 250; 00045 uint8_t tag_2 = 186; 00046 uint8_t tag_3 = 106; 00047 uint8_t tag_4 = 10; 00048 id.printf("%d", uid[0]); 00049 } 00050 } else if (previous == 0){ 00051 } else { 00052 previous = 0; 00053 } 00054 }
Generated on Sun Jul 17 2022 06:52:19 by
1.7.2