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 // FRDM-K64F (Freescale) Pin for MFRC522 reset 00005 #define MF_RESET PTD0 00006 #define SERIAL_1 00007 00008 DigitalOut LedGreen(LED2); 00009 PwmOut servo(PTC3); 00010 Serial pc(USBTX, USBRX); // serial comm on the FRDM board 00011 //MFRC522 RfChip (SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS, MF_RESET); 00012 MFRC522 RfChip (PTD2, PTD3, PTD1, PTE25, PTD0); 00013 00014 int main(void) 00015 { 00016 int fulluid=0; 00017 pc.baud(9600); 00018 00019 printf("Welcome to Project RFIDO, I hope you enjoy your experience!!!...\n\r"); 00020 00021 RfChip.PCD_Init(); 00022 00023 while (true) 00024 { 00025 LedGreen = 1; 00026 00027 // Look for new cards 00028 if ( ! RfChip.PICC_IsNewCardPresent()) 00029 { 00030 wait_ms(200); 00031 continue; 00032 } 00033 00034 // Select one of the cards 00035 if ( ! RfChip.PICC_ReadCardSerial()) 00036 { 00037 00038 wait_ms(200); 00039 continue; 00040 } 00041 LedGreen = 0; 00042 int a=0; int b=0; int c=0;int d=0; int e=0; int f=0;int g=0; int h=0; 00043 00044 // Print Card UID 00045 printf("Card UID:"); 00046 //blue.printf("Card UID:"); 00047 for (uint8_t i = 0; i < RfChip.uid.size; i++) 00048 { 00049 printf(" %X02 ", RfChip.uid.uidByte[i]); 00050 00051 //blue.printf(" %X02 ", RfChip.uid.uidByte[i]); 00052 a = RfChip.uid.uidByte[0]; 00053 b = RfChip.uid.uidByte[1]; 00054 c = RfChip.uid.uidByte[2]; 00055 d = RfChip.uid.uidByte[3]; 00056 e = RfChip.uid.uidByte[4]; 00057 f = RfChip.uid.uidByte[5]; 00058 g = RfChip.uid.uidByte[6]; 00059 h = RfChip.uid.uidByte[7]; 00060 00061 } 00062 00063 fulluid = a+b+c+d+e+f+g+h; 00064 printf("\n\r"); 00065 00066 00067 00068 //Print Card Type 00069 if(a==153) 00070 { 00071 printf("\r\nWelcome Fido, Enjoy your tasty feast!"); 00072 00073 } 00074 00075 else 00076 { 00077 printf("\r\nUnrecognized tag"); 00078 printf("\r\nSCRAM YOU FILTHY ANIMAL!!!"); 00079 } 00080 00081 printf("\n\r"); 00082 00083 00084 //blue.printf("\n\r"); 00085 00086 // Print RFID Card type 00087 uint8_t piccType = RfChip.PICC_GetType(RfChip.uid.sak); 00088 printf("PICC Type: %s \n\n\r\r", RfChip.PICC_GetTypeName(piccType)); 00089 00090 wait_ms(200); 00091 00092 while (fulluid==721) 00093 { 00094 00095 servo.period(0.020f); 00096 servo.pulsewidth_ms(2); // servo position determined by a pulsewidth between 1-2ms 00097 wait(15); 00098 servo.pulsewidth_ms(1.5f); 00099 fulluid=0; 00100 } 00101 } 00102 } 00103 00104 00105
Generated on Wed Jul 27 2022 21:33:26 by
1.7.2