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 "MFRC522.h" 00003 00004 //KL25Z Pins for MFRC522 SPI interface 00005 #define SPI_MOSI p5 00006 #define SPI_MISO p6 00007 #define SPI_SCLK p7 00008 #define SPI_CS p21 00009 DigitalOut LedRed (LED1); 00010 DigitalOut LedGreen (LED2); 00011 #define MF_RESET p8 00012 //#define UART_RX p27 00013 //#define UART_TX p28 00014 00015 //Serial DebugUART(UART_TX, UART_RX); 00016 MFRC522 RfChip (SPI_MOSI, SPI_MISO, SPI_SCLK, SPI_CS, MF_RESET); 00017 00018 int main(void) { 00019 // Set debug UART speed 00020 //DebugUART.baud(115200); 00021 00022 // Init. RC522 Chip 00023 RfChip.PCD_Init(); 00024 00025 while (true) { 00026 LedRed = 1; 00027 LedGreen = 1; 00028 00029 // Look for new cards 00030 if ( ! RfChip.PICC_IsNewCardPresent()) 00031 { 00032 wait_ms(500); 00033 continue; 00034 00035 } 00036 LedRed = 0; 00037 00038 // Select one of the cards 00039 if ( ! RfChip.PICC_ReadCardSerial()) 00040 { 00041 wait_ms(500); 00042 continue; 00043 00044 } 00045 LedRed = 1; 00046 LedGreen = 0; 00047 00048 // Print Card UID 00049 printf("Card UID: "); 00050 for (uint8_t i = 0; i < RfChip.uid.size; i++) 00051 { 00052 printf(" %X", RfChip.uid.uidByte[i]); 00053 } 00054 printf("\n\r"); 00055 00056 } 00057 }
Generated on Sat Jul 23 2022 15:31:16 by
1.7.2