HELP WITH MFRC522 and SERVO MOTORS

I am trying to write loop that turns servo motor 180 degrees after reading a specified RFID Serial Tag Number. Help please!

Start trying by using servo example codes.

I have tried servo examples but none of them include how to integrate the servo after scanning RFID tag.

I haven’t use rfid much, but I imagine you could have a boolean flag called say validCard, initially false. It would stay false as long as no card is presented or an invalid card is presented. Set it true when the card is valid.

Then probably have:

if (validCard) myServo.write(180);

You’ll need something to put the servo back where it started, ready for the next valid card.

Could you elaborate more on that code so I can run it as an example.

blakehf:
Could you elaborate more on that code

I don't have an rfid card reader, so no.

Post the code you have so far that reads the card, and I'll try to show you where to slot my suggestion in.

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

#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Servo myservo;
String card1 = “0x44, 0x21, 0XFE, 0X99”;
int i = 0;

void setup() {
lcd.begin(16, 2);
delay(1000);
myservo.attach(3);
Serial.begin(9600);
SPI.begin();
mfrc522.PCD_Init();
}

void loop() {
if (!mfrc522.PICC_IsNewCardPresent() || !mfrc522.PICC_ReadCardSerial())
return;

}

Sorry, when I said this:

Post the code you have so far that reads the card

... I should have said:

Post the code you have so far that recognises the valid card

.... implying that you already need to show how you know the card's good or not.

Looks to me (although I don't have a reader to test it) as if that code just sits and waits for a card, and tries to read it.

I can't help until you get as far as the code recognising that the card presented is card1.

blakehf:
I have tried servo examples but none of them include how to integrate the servo after scanning RFID tag.

Don't bother about RFID. You need to be able to master servos in order to run them. Then You can go for Reading an RFID and finally let the RFID trigger the servo code.

Don't throw everything into the sack, shake it and think things will work. That is the most backwards way to go. Make piece by piece work and then integrate them into one piece of code.