![]()
Hello every body I'm working on small project I want to control servo Motor 9g with RFID
I put the cables in right way and the rfid working good and scanning the cards but the servo not working
I just want when I scan the right card the servo should move = 90 degree
Here is my code :
#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h>
Servo microservo9g;
#define SS_PIN 10
#define RST_PIN 9
// definitions pine modulo RC522
MFRC522 mfrc522(SS_PIN, RST_PIN);
// Leds indicators access released or denied
int led_green = 5;
int led_red = 6;
int pos = 0;
void setup()
{
pinMode(led_green, OUTPUT);
pinMode(led_red, OUTPUT);
// Define that the servo this connected a port digital 3
microservo9g.attach(3);
// Move o servo TO a position early (cancels closed)
microservo9g.write(pos);
// starts a serial
Serial.begin(9600);
// starts SPI bus
SPI.begin();
// Starts MFRC522
mfrc522.PCD_Init();
// posts early no serial monitor
Serial.println("Scan your card");
Serial.println();
}
void loop()
{
// Waits for the approximation of the Card
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
// display UID on serial
Serial.print("UID da tag :");
String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte < 0x10 ? " " : " ");
_ Serial.print(mfrc522.uid.uidByte*, HEX);_
_ content.concat(String(mfrc522.uid.uidByte < 0x10 ? " " : " "));
content.concat(String(mfrc522.uid.uidByte, HEX));
}
Serial.println();
Serial.print("Message : ");
content.toUpperCase();*_
* // head are the Cardboard1 It was shore*
* if (content.substring(1) == "E3 44 19 13")*
* {*
* // lifts a cancel and lights the led green*
* microservo9g.write(pos);*
* digitalWrite(led_green, HIGH);
_ Serial.println("Cardboard1 - released Access !");
Serial.println();
delay(150);
microservo9g.write(pos);_
digitalWrite(led_green, LOW);
_ }*_
* // head if the read was Cardboard2*
* if (content.substring(1) == "54 74 1B 96")*
* {*
* Serial.println("Cardboard2 - Access Denied !!!");*
* Serial.println();*
* // Flashes the red LED*
* for (int i= 1; i<5 ; i++)*
* {*
* digitalWrite(led_red, HIGH);
_ delay(100);_
digitalWrite(led_red, LOW);
_ delay(100);
}
}
delay(500);
}
*_