#include <SPI.h> #include <MFRC522.h> MFRC522 mfrc522(10,9); String x = "ArduBlock"; byte cardx[4]= {0x3F,0x01,0x23,0x44}; String cardreaded(byte *buffer,byte bufferSize) { String card=""; for (byte i=0; i<bufferSize; i++) { card+=String(buffer[i]<0x10 ? " 0" : " "); card+=String(buffer[i],HEX); } return card; } void setup() { Serial.begin(9600); SPI.begin(); mfrc522.PCD_Init(); } void loop() { if (mfrc522.PICC_ReadCardSerial() == 1 | mfrc522.PICC_IsNewCardPresent() == 1) { x = cardreaded(mfrc522.uid.uidByte, mfrc522.uid.size); } Serial.println(x); if (x == " b0 43 8e 1a") { pinMode(2, OUTPUT); digitalWrite(2, 1); delay(1000); pinMode(2, OUTPUT); digitalWrite(2, 0); void(* resetFunc) (void) = 0; resetFunc(); } }
Открыть пример: Online ArduBlock
Видеоурок: