Untitled
unknown
c_cpp
a month ago
1.6 kB
1
Indexable
Never
/* Bu kod size attığım düzenelemer yapacğaız her okuttuğumuzda sadece id yazacak şekile getireceğim izleyiyor musunuz? */ #include <SPI.h> #include <MFRC522.h> #define SS_PIN 5 #define RST_PIN 0 MFRC522 rfid(SS_PIN, RST_PIN); MFRC522::MIFARE_Key key; String ustKart=""; String altKart=""; byte nuidPICC[4]; /okutulan kart'in id'si/ void setup() { Serial.begin(9600); SPI.begin(); rfid.PCD_Init(); for (byte i = 0; i < 6; i++) { key.keyByte[i] = 0xFF; } Serial.println(""); Serial.println(""); Serial.println(""); Serial.println("KART OKUMAYA HAZIR, YAZILIM BAŞLADI..."); Serial.println(""); Serial.println(""); Serial.println(""); } void loop() { if (!rfid.PICC_IsNewCardPresent()) return; if (!rfid.PICC_ReadCardSerial()) return; MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak); if (piccType != MFRC522::PICC_TYPE_MIFARE_MINI && piccType != MFRC522::PICC_TYPE_MIFARE_1K && piccType != MFRC522::PICC_TYPE_MIFARE_4K) { return; } String uidString = ""; for (byte i = 0; i < rfid.uid.size; i++) { uidString += String(rfid.uid.uidByte[i] < 0x10 ? "0" : ""); // Add leading zero if necessary uidString += String(rfid.uid.uidByte[i], HEX); // Convert byte to hexadecimal string } uidString.toUpperCase(); Serial.println(uidString); rfid.PICC_HaltA(); rfid.PCD_StopCrypto1(); } void printHex(byte *buffer, byte bufferSize) { for (byte i = 0; i < bufferSize; i++) { Serial.print(buffer[i] < 0x10 ? " 0" : " "); Serial.print(buffer[i], HEX); } }
Leave a Comment