Advertisement
21ani

rfid

Jul 12th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include<SPI.h>
  2. #include<MFRC522.h>
  3.  
  4. //const int pin_ss=10;
  5. const int pin_ss=6;
  6. const int pin_rst=9;
  7. const int pin_sp=8;
  8. const int led=5;
  9.  
  10. MFRC522 rfid(pin_ss,pin_rst);
  11.  
  12. void setup() {
  13.   Serial.begin(9600);
  14.   SPI.begin();
  15.   rfid.PCD_Init();
  16.   pinMode(led,OUTPUT);
  17. }
  18.  
  19. void loop() {
  20.   if(!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()){
  21.     return;
  22.   }
  23.   String id;
  24.   id=String(rfid.uid.uidByte[0]) + String(rfid.uid.uidByte[1]) + String(rfid.uid.uidByte[2]) + String(rfid.uid.uidByte[3]);
  25.   Serial.print("ID Anda: ");
  26.   Serial.println(id);
  27.  
  28. //  if(id=="231372025"){
  29. //    digitalWrite(led,HIGH);
  30. //  }
  31. //  if(id=="25216737217"){
  32. //    digitalWrite(led,LOW);
  33. //  }
  34.  
  35.   rfid.PICC_HaltA();
  36.   rfid.PCD_StopCrypto1();  
  37.  
  38.  
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement