# Rfid

**URL:** <https://forum.arduino.cc/t/rfid/598153>\
**Category:** Programming\
**Created:** [June 21, 2019, 1:58pm UTC](https://forum.arduino.cc/t/rfid/598153 "2019-06-21T13:58:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shanmugaraja](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@shanmugaraja](https://forum.arduino.cc/u/shanmugaraja)\
**Post date:** [June 21, 2019, 1:58pm UTC](https://forum.arduino.cc/t/rfid/598153/1 "2019-06-21T13:58:19Z")

</div>

`#include \<SPI.h\>'  
#include \<MFRC522.h\>  
#include \<Servo.h\>  
Servo myservo;  
int potpin = 0;  
int val;  
#define SS\_PIN 10  
#define RST\_PIN 9  
MFRC522 mfrc522(SS\_PIN, RST\_PIN);

void setup() {  
Serial.begin(115200);  
SPI.begin();  
mfrc522.PCD\_Init();  
Serial.println("Arduino RFID lock");  
Serial.println("");  
pinMode(LED1,OUTPUT);  
pinMode(LED2,OUTPUT);  
myservo.attach(3);  
myservo.write( 0 );  
}

void loop(){  
val = analogRead(potpin);  
if ( !mfrc522.PICC\_IsNewCardPresent() ){  
return;  
}  
if ( !mfrc522.PICC\_ReadCardSerial() ) {  
return;  
}

String content= "";  
byte letter;  
for( byte i = 0; i \< mfrc522.uid.size; i++ ){  
content.concat(String(mfrc522.uid.uidByte\*, HEX));\*  
_if( i \< mfrc522.uid.size-1 ) content+="-";_  
_}_  
_content.toUpperCase();_  
_Serial.println();_  
_Serial.println("UID tag :'" + content + "'");_  
_Serial.print(content);_  
_if( content== "55-33-2C-83")_  
_val = map(val, 0, 1023, 0, 150);_  
_else if( content=="91-2B-D2-2F")_

- val = map (val, 0, 1023, 0, 60);\*  
_myservo.write(val);_  
_delay(15);_  
_}_  
_This is my code .i want to do my servo to rotate 0to180 when rfid scan specific tag.and rotate 0 to 60 when scan another tag._  
_But the issue is .i want to change the servo pos when rfid scan once ._  
_The above program runs when the rfid scan the tag after removing it didn't work. Pls help by providing some codes._

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [June 21, 2019, 2:31pm UTC](https://forum.arduino.cc/t/rfid/598153/2 "2019-06-21T14:31:58Z")

</div>

Please read [read this before posting a programming question](http://forum.arduino.cc/index.php?topic=97455.0) and post your code in code tags to stop it turning into italics

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 5, 2021, 11:53pm UTC](https://forum.arduino.cc/t/rfid/598153/3 "2021-05-05T23:53:46Z")

</div>

Closed on May 5, 2021, 11:53pm UTC


