my code doesn't work

could someone tell me what is wrong??

this is all my code

#include <Servo.h>
#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 10
#define RST_PIN 9
#define GREEN_LED 6
#define RED_LED 7
#define SS_PIN 10
#define RST_PIN 9

Servo myservo;

MFRC522 mfrc522(SS_PIN, RST_PIN);

unsigned char reading_card[5]; //for reading card
unsigned char master[5] = {165,200,111,42,40}; // allowed card
unsigned char i;

void indication(int led);
void allow();
void denied();
int pos = 0;
void setup()
{
   myservo.attach(3);
  Serial.begin(9600);
  SPI.begin();
  mfrc522.init();
  pinMode(GREEN_LED, OUTPUT);
  pinMode(RED_LED, OUTPUT);
  myservo.write(0);
}

void loop()
{
    if (mfrc522.isCard())
    {
        if (mfrc522.readCardSerial())
        {
                /* Reading card */
                Serial.println(" ");
                Serial.println("Card found");
                Serial.println("Cardnumber:");
                for (i = 0; i < 5; i++)
                {     
                  Serial.print(rfid.serNum[i]);
                  Serial.print(" ");
                  reading_card[i] = rfid.serNum[i];
                }
                Serial.println();
                //verification
                for (i = 0; i < 5; i++)
                {
                  if (reading_card[i]!=master[i])
                  {
                    break;
                  }
                }
                if (i == 5)
                {
                  allow();
                }
                else
                {
                  denied();
                }
         }
    }
    mfrc522.halt();
}

void allow()
{
  Serial.println("Access accept!");
  indication(GREEN_LED);
  myservo.write(180);
  digitalWrite(GREEN_LED, HIGH);
  delay(2000);
  digitalWrite(GREEN_LED, LOW);
 myservo.write(0);
}
void denied()
{
  Serial.println("Access denied!");
  indication(RED_LED);
}
void indication(int led)
{
  digitalWrite(led, HIGH);
  delay(1000);
  digitalWrite(led, LOW);

}

You either don't have the library installed, or it is installed in the wrong place (which amount to the same thing)

Please use CODE TAGS when posting code.

AWOL:
You either don't have the library installed, or it is installed in the wrong place (which amount to the same thing)

Please use CODE TAGS when posting code.

could you tell me how?
I'm new using rfid!

Where did you put the file named "MFRC522.h" ?

AWOL:
Where did you put the file named "MFRC522.h" ?

I did not create any file with that name
what you mean?

I mean, "where did you put the library MFRC522?"

AWOL:
I mean, "where did you put the library MFRC522?"

I didn't know that I had to do that
I only wrote code

I don't know what I doing it wrong

this is all my code

#include <RFID.h>
#include <Servo.h>
#include <SPI.h>



#define SS_PIN 10
#define RST_PIN 9
#define GREEN_LED 6
#define RED_LED 7
Servo myservo;

MFRC522 rfid (SS_PIN, RST_PIN);

unsigned char reading_card[5]; //for reading card
unsigned char master[5] = {
  165,200,111,42,40}; // allowed card
unsigned char i;

void indication(int led);
void allow();
void denied();
int pos = 0;
void setup()
{
  myservo.attach(3);
  Serial.begin(9600);
  SPI.begin();
  MFRC522.init();
  pinMode(GREEN_LED, OUTPUT);
  pinMode(RED_LED, OUTPUT);
  myservo.write(0);
}

void loop()
{
  if (MFRC522.isCard())
  {
    if (MFRC522.readCardSerial())
    {
      /* Reading card */
      Serial.println(" ");
      Serial.println("Card found");
      Serial.println("Cardnumber:");
      for (i = 0; i < 5; i++)
      {     
        Serial.print(MFRC522.serNum[i]);
        Serial.print(" ");
        reading_card[i] = MFRC522.serNum[i];
      }
      Serial.println();
      //verification
      for (i = 0; i < 5; i++)
      {
        if (reading_card[i]!=master[i])
        {
          break;
        }
      }
      if (i == 5)
      {
        allow();
      }
      else
      {
        denied();
      }
    }
  }
  MFRC522.halt();
}

void allow()
{
  Serial.println("Access accept!");
  indication(GREEN_LED);
  myservo.write(180);
  digitalWrite(GREEN_LED, HIGH);
  delay(2000);
  digitalWrite(GREEN_LED, LOW);
  myservo.write(0);
}
void denied()
{
  Serial.println("Access denied!");
  indication(RED_LED);
}
void indication(int led)
{
  digitalWrite(led, HIGH);
  delay(1000);
  digitalWrite(led, LOW);

}

Cross-posting is a fast-track to the sin-bin (what a lot of hyphens!)

DO NOT CROSS-POST, IT WASTES TIME.

The class MFRC522 is defined in RFID.h
The compiler must be able to find the RFID.h and the RFID library. I assume you have that now.

This code line : MFRC522 mfrc522(SS_PIN, RST_PIN);
It creates the actual class, called mfrc522. The "mfrc522" is the variable (not just a variable, but a complete class) that is in the ram memory of the Arduino. The "MFRC522" is the definition for that class.

In your code you use MFRC522.init(), but you must use the actual class that you created, not the definition.
So please change it into : mfrc522.init();

You use the RFID library, please tell us which one (just a link to it).

AWOL:
Cross-posting is a fast-track to the sin-bin (what a lot of hyphens!)

DO NOT CROSS-POST, IT WASTES TIME.

i need help buddy ,tomorrow i have to deliver a project please

Peter_n:
The class MFRC522 is defined in RFID.h
The compiler must be able to find the RFID.h and the RFID library. I assume you have that now.

This code line : MFRC522 mfrc522(SS_PIN, RST_PIN);
It creates the actual class, called mfrc522. The "mfrc522" is the variable (not just a variable, but a complete class) that is in the ram memory of the Arduino. The "MFRC522" is the definition for that class.

In your code you use MFRC522.init(), but you must use the actual class that you created, not the definition.
So please change it into : mfrc522.init();

You use the RFID library, please tell us which one (just a link to it).

thanks buddy let me check

alexrock1:

AWOL:
Cross-posting is a fast-track to the sin-bin (what a lot of hyphens!)

DO NOT CROSS-POST, IT WASTES TIME.

i need help buddy ,tomorrow i have to deliver a project please

That's not my problem.

My problem is members who get pissed-off by spending wasting their time answering a question, only to find that the question has already been answered in another cross-posted thread.

AWOL:

alexrock1:

AWOL:
Cross-posting is a fast-track to the sin-bin (what a lot of hyphens!)

DO NOT CROSS-POST, IT WASTES TIME.

i need help buddy ,tomorrow i have to deliver a project please

That's not my problem.

My problem is members who get pissed-off by spending wasting their time answering a question, only to find that the question has already been answered in another cross-posted thread.

thanks you are a great moderator you are the man

thanks you are a great moderator you are the man

I wouldn't go that far but usually he's ok. XD

I would also point out that he was the first person to try to help you. If you don't understand the answers then either Google it or ask about the part you don't understand. Nobody minds helping someone who is trying to help themselves.

Footnote: The title "my code doesn't work" is both pointless and inaccurate.

If your code worked, you wouldn't be posting here, but if your code didn't work (as you expected) it would at least have compiled.
If your code doesn't compile, it cannot run.

AWOL:
Footnote: The title "my code doesn't work" is both pointless and inaccurate.

If your code worked, you wouldn't be posting here, but if your code didn't work (as you expected) it would at least have compiled.
If your code doesn't compile, it cannot run.

:sleeping:

You are the best