Untitled
#include <SPI.h> #include <MFRC522.h> #define SDA_PIN 53 #define RST_PIN 5 MFRC522 mfrc522(SDA_PIN, RST_PIN); void setup() { Serial.begin(9600); SPI.begin(); mfrc522.PCD_Init(); } void loop() { if (!mfrc522.PICC_IsNewCardPresent()) { return; } if (!mfrc522.PICC_ReadCardSerial()) { return; } Serial.println("Karte entdeckt!"); byte block = 4; byte data[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10}; MFRC522::StatusCode status = mfrc522.MIFARE_Write(block, data, 16); if (status != MFRC522::STATUS_OK) { Serial.print("Schreibfehler: "); Serial.println(mfrc522.GetStatusCodeName(status)); } else { Serial.println("Daten erfolgreich geschrieben."); } delay(1000); }
Leave a Comment