RFID to turn Servo

So I have an Adafruit PN532 NFC/RFID Controller Shield connected to my arduino uno. I’m trying to get it so that it reads an RFID chip and turns the servo. I got it do that but it does it with any RFID chip and I want it to work with a specific RFID chip code. I don’t really understand the whole code that reads the RFID I just used the example code that the Adafruit PN532 library had and modified it to get it to read RFID chips. If you know anyway I could get it to turn the servo only when it has a specific RFID code that would be great help.

rfid_modifidied_example.ino (2.25 KB)

It would help if you first tried to learn how the code you have works. Going much further without that will be an exercise in futility.

You have an array called uid that stored the id from the chip you read. You will need similar arrays to store the codes for the chips you want to react to. Once you have that, you can use a for loop to cycle through the various id's you have hard coded to see if one matches the id coming from the chip you read.

If that doesn't make any sense, then you've got some studying to do before you try to go much further.

As an extra hint to what Delta_G said, here's an example of an array which could be used to hold a known card's id number. Change the zeros to the numbers displayed in the serial output.

Servo myservo;
int pos = 0;
uint8_t servoCardId[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the ID of servo card

I included a couple lines from the program to give you an idea where you should add it.

There's a "for" loop in the program. This same loop could be used to compare the "servoCardId" array with the numbers being displayed from the card reader.

It would be helpful if you posted your code inline to the forum. This way we could look at the code without having to create a directory for it.

Make sure you check back here if you're still having trouble.