Arduino程式碼
Please connect to Port A(22、21),Use the RFID Unit to read the Fudan card ID
and display the ID on the screen. RFID偵測連接端口A(22、21),使用RFID Unit讀取卡片並在螢幕上顯示
*/
MFRC522 mfrc522(0x28);  // Create MFRC522 instance.   
    M5.begin();             // Init M5Stack.   
    M5.Power.begin();       // Init power   
    M5.lcd.setTextSize(2);  // Set the text size to 2.   
    M5.Lcd.println("MFRC522 Test"); 
    Wire.begin();  // Wire init, adding the I2C bus.   
    mfrc522.PCD_Init();  // Init MFRC522.  初始化 MFRC522 
    M5.Lcd.println("Please put the card\n\nUID:"); 
    M5.Lcd.setCursor(40, 47); 
    if (!mfrc522.PICC_IsNewCardPresent() || 
        !mfrc522.PICC_ReadCardSerial()) {  //如果没有讀到新的卡片 
    M5.Lcd.fillRect(42, 47, 320, 20, BLACK); 
    for (byte i = 0; i < mfrc522.uid.size; 
         i++) {  // Output the stored UID data.   
        M5.Lcd.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); 
        M5.Lcd.println(mfrc522.uid.uidByte[i], HEX); 
        M5.Lcd.println(mfrc522.uid.uidByte[i], DEX);