Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Mega ADK RFID-Controlled Stepper Motor System with DFPlayer Mini and LED Indicators

View and Edit Project In Cirkit DesignerImage of Arduino Mega ADK RFID-Controlled Stepper Motor System with DFPlayer Mini and LED Indicators

Circuit Documentation

Summary

This circuit is designed to integrate various components including an Arduino Mega ADK, DFPlayer Mini, RFID-RC522, stepper motor, pushbutton, loudspeaker, and multiple LEDs. The system is capable of reading RFID tags, controlling a stepper motor, playing audio files, and providing visual feedback through LEDs.

Component List

  1. Arduino Mega ADK (Rev3)

    • Description: A microcontroller board based on the ATmega2560.
    • Pins: A0-A15, D0-D53, ICSP, RESET, 3V3, 5V, GND, VIN, IOREF
  2. DFPlayer MINI

    • Description: A small MP3 player module with a simplified output directly to the speaker.
    • Pins: VCC, BUSY, RX, USB -, TX, USB +, DAC_R, K2/ADC_KEY, DAC_L, K1/ADC_KEY, SPK1, IO 2, GND, SPK2, IO 1
  3. Loudspeaker

    • Description: A device that converts electrical signals into sound.
    • Pins: pin1, pin2
  4. LED: Two Pin (blue)

    • Description: A blue light-emitting diode.
    • Pins: cathode, anode
  5. LED: Two Pin (green)

    • Description: A green light-emitting diode.
    • Pins: cathode, anode
  6. Resistor

    • Description: A passive electrical component that limits current flow.
    • Pins: pin1, pin2
    • Properties: Various resistances (1 Ohm, 200 Ohms, 220 Ohms)
  7. Stepper Motor (Bipolar)

    • Description: A motor that moves in discrete steps, used for precise control.
    • Pins: D, B, C, A
  8. Pushbutton

    • Description: A simple switch mechanism for controlling some aspect of a machine or process.
    • Pins: Pin 1, Pin 2, Pin 3, Pin 4
  9. RFID-RC522

    • Description: A low-cost RFID reader module.
    • Pins: VCC (3.3V), RST, GND, IRQ, MISO, MOSI, SCK, SDA

Wiring Details

Arduino Mega ADK (Rev3)

DFPlayer MINI

Loudspeaker

LED: Two Pin (blue)

LED: Two Pin (green)

Resistor

Stepper Motor (Bipolar)

Pushbutton

RFID-RC522

Documented Code

#include <SPI.h>
#include <MFRC522.h>
#include <Stepper.h>
#include "DFRobotDFPlayerMini.h"
#include <SoftwareSerial.h>

// Pin Definitions for Mega 2560
#define RST_PIN 9          // Reset pin for RFID
#define RFID_CS_PIN 8      // RFID Chip Select pin
#define LED1_PIN 22        // System LED 1 (indicates system ON)
#define LED2_PIN 23        // System LED 2 (indicates system ON)
#define LED3_PIN 25        // System LED 3 (indicates system ON)
#define LED4_PIN 24        // System LED 4 (indicates system ON)
#define LED5_PIN 15        // Motor movement LED 1
#define LED6_PIN 17
#define LED7_PIN 16
#define LED8_PIN 18       // Motor movement LED 2
#define SWITCH_PIN 14      // Switch to reset the system
#define STEPPER_PIN1 4     // Stepper motor control pins
#define STEPPER_PIN2 5
#define STEPPER_PIN3 6
#define STEPPER_PIN4 7     // Updated motor connection pin
#define SOUND_RX_PIN 10    // Sound module RX pin
#define SOUND_TX_PIN 11    // Sound module TX pin

// Initialize RFID reader
MFRC522 mfrc522(RFID_CS_PIN, RST_PIN);

// Initialize the stepper motor
const int stepsPerRevolution = 200; // Steps per revolution for the motor
Stepper myStepper(stepsPerRevolution, STEPPER_PIN1, STEPPER_PIN2, STEPPER_PIN3, STEPPER_PIN4);

// Initialize sound system
SoftwareSerial mySoftwareSerial(SOUND_RX_PIN, SOUND_TX_PIN); // RX, TX
DFRobotDFPlayerMini myDFPlayer;

// UIDs of the RFID cards
const byte firstUID[] = {0xA1, 0x9A, 0x1D, 0x1D};  // First RFID UID
const byte secondUID[] = {0xB4, 0x90, 0xDE, 0x03}; // Second RFID UID

// System state variable
bool systemOn = false;

void setup() {
  Serial.begin(9600); // Debugging
  Serial.println("Initializing system...");

  // Initialize RFID
  SPI.begin();
  mfrc522.PCD_Init();
  Serial.println("RFID reader initialized.");

  // Initialize LEDs
  pinMode(LED1_PIN, OUTPUT);
  pinMode(LED2_PIN, OUTPUT