The circuit in question is designed to interface an Arduino Nano with an RFID-RC522 module, a Tower Pro SG90 servo motor, a piezo buzzer, and a green LED. The purpose of the circuit is to detect RFID tags, actuate a servo, and provide audio-visual feedback upon successful tag detection. The Arduino Nano serves as the central processing unit, controlling the RFID reader for tag detection, driving the servo motor to a specific position, and triggering the buzzer and LED to indicate the detection event.
D7
connected to the cathode of the green LED and pin 1 of the piezo buzzerGND
connected to the anode of the green LED, GND of the servo, and pin 2 of the piezo buzzerD3
connected to the signal pin of the servo5V
connected to the +5V of the servo3V3
connected to the 3.3V of the RFID-RC522D9
connected to the RST pin of the RFID-RC522D10
connected to the SDA pin of the RFID-RC522D11/MOSI
connected to the MOSI pin of the RFID-RC522D12/MISO
connected to the MISO pin of the RFID-RC522D13/SCK
connected to the SCK pin of the RFID-RC5223.3V
connected to 3V3 of the Arduino NanoGND
connected to GND of the Arduino NanoRST
connected to D9 of the Arduino NanoSDA
connected to D10 of the Arduino NanoMOSI
connected to D11/MOSI of the Arduino NanoMISO
connected to D12/MISO of the Arduino NanoSCK
connected to D13/SCK of the Arduino NanoSignal
connected to D3 of the Arduino Nano+5V
connected to 5V of the Arduino NanoGND
connected to GND of the Arduino Nanopin 1
connected to D7 of the Arduino Nanopin 2
connected to GND of the Arduino Nanocathode
connected to D7 of the Arduino Nanoanode
connected to GND of the Arduino Nano#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 rfid(SS_PIN, RST_PIN);
Servo myServo;
int buzzerPin = 7;
void setup() {
Serial.begin(9600);
SPI.begin();
rfid.PCD_Init();
myServo.attach(3);
pinMode(buzzerPin, OUTPUT);
Serial.println("Ready to Scan!");
}
void loop() {
if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) {
return;
}
Serial.println("Card detected!");
String cardUID = "";
for (byte i = 0; i < rfid.uid.size; i++) {
cardUID += String(rfid.uid.uidByte[i], HEX);
}
Serial.print("DATA,TIME,");
Serial.print(cardUID);
Serial.println(",Accepted");
digitalWrite(buzzerPin, HIGH);
delay(100);
digitalWrite(buzzerPin, LOW);
myServo.write(90);
delay(2000);
myServo.write(0);
rfid.PICC_HaltA();
}
SS_PIN
and RST_PIN
are defined for the RFID reader's slave select and reset pins.MFRC522
object and a Servo
object are instantiated.buzzerPin
is defined and set to digital pin 7 on the Arduino Nano.setup()
function, serial communication is initiated, SPI is begun, and the RFID reader is initialized. The servo is attached to pin 3, and the buzzer pin is set as an output. A ready message is printed to the serial monitor.loop()
function continuously checks for new RFID cards. If a card is detected, its UID is read and printed to the serial monitor along with a timestamp and an "Accepted" message.