Created
October 8, 2019 09:57
-
-
Save RobolinkAkademi/d264dd212c2fb6565fe71662d05ec91f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SPI.h> | |
#include <MFRC522.h> | |
const byte YESIL_LED = 4; | |
const byte KIRMIZI_LED = 2; | |
MFRC522 rfid(10, 9);//RFID Chip Select ve Reset pinlerinin ayarlarını yapıyoruz. | |
byte Kart[4] = {53, 122, 201, 226}; // {53, 122, 201, 226} buraya kendi okuttuğunuz kartın ID numarasını yazmalısınız. | |
boolean Yetki; | |
void setup() | |
{ | |
Serial.begin(9600); | |
pinMode(KIRMIZI_LED, OUTPUT); | |
pinMode(YESIL_LED, OUTPUT); | |
SPI.begin(); | |
rfid.PCD_Init(); | |
} | |
void loop() | |
{ | |
Yetki = true; | |
if ( rfid.PICC_IsNewCardPresent()) | |
{ | |
if ( rfid.PICC_ReadCardSerial()) | |
{ Serial.print("Okunan Kart ID: "); | |
Serial.print(rfid.uid.uidByte[0]); | |
Serial.print(","); | |
Serial.print(rfid.uid.uidByte[1]); | |
Serial.print(","); | |
Serial.print(rfid.uid.uidByte[2]); | |
Serial.print(","); | |
Serial.println(rfid.uid.uidByte[3]); | |
} | |
for (int i = 0; i < 4; i++) | |
{ | |
if (rfid.uid.uidByte[i] != Kart[i]) | |
{ | |
Yetki = false; | |
} | |
} | |
if (Yetki == true) | |
{ | |
Serial.println("Yetki Onaylandi..."); | |
digitalWrite(YESIL_LED, HIGH); | |
delay(1000); | |
digitalWrite(YESIL_LED, LOW); | |
} | |
else | |
{ | |
Serial.println("Yetki Onaylanmadi..."); | |
digitalWrite(KIRMIZI_LED, HIGH); | |
delay(1000); | |
digitalWrite(KIRMIZI_LED, LOW); | |
} | |
rfid.PICC_HaltA(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment