1#include <Servo.h>
2#include <SPI.h>
3#include <RFID.h>
4
5RFID rfid(10, 9);
6
7byte kart[5] = {208,74,76,37,243};
8Servo myservo;
9boolean card;
10
11void setup()
12{
13
14 Serial.begin(9600);
15 SPI.begin();
16 rfid.init();
17 myservo.attach(3);
18 myservo.write(100);
19
20}
21
22void loop()
23{
24
25 if (rfid.isCard())
26 {
27
28
29 if (rfid.readCardSerial())
30 {
31 Serial.print("Found ID: ");
32 Serial.print(rfid.serNum[0]);
33 Serial.print(",");
34 Serial.print(rfid.serNum[1]);
35 Serial.print(",");
36 Serial.print(rfid.serNum[2]);
37 Serial.print(",");
38 Serial.print(rfid.serNum[3]);
39 Serial.print(",");
40 Serial.println(rfid.serNum[4]);
41
42 }
43 for (int i = 1; i < 5; i++)
44 {
45 if (rfid.serNum[0] == kart[0] && rfid.serNum[1] == kart[1] && rfid.serNum[2] == kart[2] && rfid.serNum[3] == kart[3] && rfid.serNum[4] == kart[4])
46 {
47 card = true;
48 }
49 else {
50 card = false;
51 }
52 }
53 if (card == true)
54 {
55 Serial.println("Correct Card");
56 myservo.write(20);
57 delay(15000);
58 myservo.write(100);
59 }
60 else
61 {
62 Serial.println("Wrong Card");
63
64 }
65 rfid.halt();
66 }
67}
68