rfid wont work dont know y
#include <ESP32Servo.h>
#include <Password.h>
#include <Keypad.h>
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 2
#define RST_PIN 4
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
Servo myservo;
Password password = Password( "2692" ); // Set password as
const byte ROWS = 4; // set four rows
const byte COLS = 4; // set four columns
char keys[ROWS][COLS] = { // Define the keymap
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {36, 39, 34, 35};
byte colPins[COLS] = {32, 33, 25, 26};
// Create the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins,
ROWS, COLS );
void setup() {
Serial.begin(9600);
delay(200);
pinMode(13, OUTPUT); // Set green LED as output
pinMode(12, OUTPUT); // Set red LED as output
myservo.attach(4); // Pin connected to servo
myservo.write(0);
keypad.addEventListener(keypadEvent); // Add an event listener to
// detect keypresses
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
Serial.println();
Serial.println("Approximate your card to the reader...");
}
void loop() {
keypad.getKey();
}
void keypadEvent(KeypadEvent eKey) {
switch (keypad.getState()) {
case PRESSED:
Serial.print("Pressed: ");
Serial.println(eKey);
switch (eKey) {
case '*': checkPassword(); break;
case '#': password.reset(); break;
default: password.append(eKey);
}
}
}
void loop1()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
Serial.print("UID tag :");
String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
Serial.println();
Serial.print("Message : ");
content.toUpperCase();
if (content.substring(1) == "B5 80 02 75") //change here the UID of the card/cards that you want to give access
{
Serial.println("Authorized access");
Serial.println();
myservo.write(90); // Move servo arm 90 degrees
digitalWrite(13, HIGH); // Turn on green LED
delay(500); // Wait 5 seconds
digitalWrite(13, LOW); // Turn off green LED
password.reset();
}
else {
Serial.println(" Access denied");
myservo.write(0);
digitalWrite(12, HIGH); // Turn on red LED
delay(500); // Wait 5 seconds
digitalWrite(12, LOW); // Turn off red LED
}
}
void checkPassword() {
if (password.evaluate() ) {
Serial.println("Success"); // If the password is correct...
myservo.write(90); // Move servo arm 90 degrees
digitalWrite(13, HIGH); // Turn on green LED
delay(500); // Wait 5 seconds
digitalWrite(13, LOW); // Turn off green LED
password.reset(); } else {
Serial.println("Wrong"); // If the password is incorrect...
myservo.write(0);
digitalWrite(12, HIGH); // Turn on red LED
delay(500); // Wait 5 seconds
digitalWrite(12, LOW); // Turn off red LED
}
}