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

Arduino-Controlled Stepper and DC Motor with Relay and DRV8825 Driver

View and Edit Project In Cirkit DesignerImage of Arduino-Controlled Stepper and DC Motor with Relay and DRV8825 Driver

Circuit Documentation

Summary of the Circuit

This circuit is designed to control a Nema 17 stepper motor using a DRV8825 stepper motor driver, which is interfaced with an Arduino UNO microcontroller. Additionally, the circuit includes a 5V 8-channel relay module to control a DC motor and a power supply to provide the necessary voltage and current to the system.

Component List

Nema 17 Stepper Motor (42-STH48)

DRV8825 Stepper Motor Driver

Arduino UNO

DC Motor

5V 8-Channel Relay Module

Power Supply

Wiring Details

Nema 17 Stepper Motor (42-STH48)

DRV8825 Stepper Motor Driver

Arduino UNO

DC Motor

5V 8-Channel Relay Module

Power Supply

Documented Code

// Pin assignments
const int stepPin = 3;  // Stepper motor step
const int dirPin = 4;   // Stepper motor direction
const int relayPin = 6; // Relay for DC motor

void setup() {
  // Initialize stepper motor pins
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  
  // Initialize relay pin
  pinMode(relayPin, OUTPUT);
  
  // Set initial direction for the stepper
  digitalWrite(dirPin, HIGH);
}

void loop() {
  // Stepper motor control
  for (int i = 0; i < 200; i++) {  // 200 steps for one revolution (depends on your motor/driver)
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(1000);  // Control speed by changing delay
    digitalWrite(stepPin, LOW);
    delayMicroseconds(1000);
  }
  
  delay(1000);  // Wait between revolutions
  
  // DC motor control via relay
  digitalWrite(relayPin, HIGH);  // Turn on DC motor
  delay(5000);  // Run for 5 seconds
  digitalWrite(relayPin, LOW);   // Turn off DC motor
  delay(1000);  // Wait before next cycle
}

The code provided is for the Arduino UNO microcontroller. It initializes the pins connected to the DRV8825 stepper motor driver and the relay module. The loop function controls the stepper motor by sending pulses to the stepPin and toggles the direction using the dirPin. It also controls the DC motor by activating the relay connected to relayPin.