#include
#include
# define SS_PIN 10
9 # define RST_PIN
Servo myservo;
Int pos=0;//steering gear
MFRC522 rfid (SS_PIN RST_PIN);//instantiate the class
//initialize the array is used to store read NUID
Byte nuidPICC [4].
Void setup () {
Serial.begin(9600);
SPI. The begin ();//initialize the SPI bus
Rfid. PCD_Init ();//initialize the MFRC522
Myservo. Attach (9);
PinMode (7, the OUTPUT);
}
Void loop () {
//to find card
If (! Rfid. PICC_IsNewCardPresent ())
return;
//verification NUID is readable
If (! Rfid. PICC_ReadCardSerial ())
return;
MFRC522: : PICC_Type piccType=rfid. PICC_GetType (rfid) uid) sak);
//check whether MIFARE card type
If (piccType!=MFRC522: : PICC_TYPE_MIFARE_MINI & amp; &
PiccType!=MFRC522: : PICC_TYPE_MIFARE_1K & amp; &
PiccType!=MFRC522: : PICC_TYPE_MIFARE_4K) {
Serial. Println (" does not support read the card type ");
return;
}
//to save NUID to nuidPICC array
For (byte I=0; i <4. I++) {
NuidPICC [I]=rfid. Uid. UidByte [I];
}
Serial. Print (" hexadecimal UID: ");
PrintHex (rfid) uid) uidByte, rfid uid. Size);
Serial. Println ();
Serial. Print (" decimal UID: ");
PrintDec (rfid) uid) uidByte, rfid uid. Size);
Serial. Println ();
//that placed the IC card to enter a dormant state of reading card area, not repeat card read
Rfid. PICC_HaltA ();
//stop reading card module coding
Rfid. PCD_StopCrypto1 ();
}
{
}
}
Void printHex (byte * buffer, byte bufferSize) {
For (byte I=0; i
Serial. Print (buffer [I], HEX);
}
}
Void printDec (byte * buffer, byte bufferSize) {
For (byte I=0; i
Serial. Print (buffer [I], DEC);
}
}
How to set up if I test my UID card is set in advance, and then turn control of steering gear,
CodePudding user response:
In front of the steering gear control judgment, to read out whether set up card for you