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.
Fork of RFID-RC522 by
main.cpp
00001 #include "mbed.h" 00002 #include "MFRC522.h" 00003 #define MF_RESET D8 00004 00005 DigitalOut LedGreen(LED1); 00006 Serial pc(SERIAL_TX, SERIAL_RX); 00007 00008 MFRC522 RfChip (SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS, MF_RESET); 00009 00010 int main(void) { 00011 int data[10]; 00012 pc.printf("starting...\n"); 00013 00014 // Init. RC522 Chip 00015 RfChip.PCD_Init(); 00016 00017 while (true) { 00018 LedGreen = 1; 00019 00020 // Look for new cards 00021 if(data[0] == 199 && data[1] == 230 &&data[2] == 46 &&data[3] == 0 ) 00022 { 00023 pc.printf(" admin \n"); 00024 data[0] = 0; 00025 data[1] = 0; 00026 data[2] = 0; 00027 data[3] = 0; 00028 } 00029 if ( ! RfChip.PICC_IsNewCardPresent()) 00030 { 00031 wait_ms(500); 00032 continue; 00033 } 00034 00035 // Select one of the cards 00036 if ( ! RfChip.PICC_ReadCardSerial()) 00037 { 00038 wait_ms(500); 00039 continue; 00040 } 00041 00042 LedGreen = 0; 00043 00044 // Print Card UID 00045 pc.printf("Card UID: "); 00046 for (uint8_t i = 0; i < RfChip.uid.size; i++) 00047 { 00048 data[i] = RfChip.uid.uidByte[i]; 00049 pc.printf("%d ", data[i]); 00050 00051 } 00052 00053 //pc.printf("\n\r"); 00054 //pc.printf("\n\r"); 00055 //char data[0]; 00056 //pc.printf(" %X02", data[0]); 00057 //pc.printf(" %s\n", data[0]); 00058 00059 pc.printf("\n\r"); 00060 } 00061 }
Generated on Wed Jul 13 2022 19:18:44 by
