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

Arduino-Controlled Bipolar Stepper Motor with 12V Battery Power

View and Edit Project In Cirkit DesignerImage of Arduino-Controlled Bipolar Stepper Motor with 12V Battery Power

Circuit Documentation

Summary

This circuit is designed to control a bipolar stepper motor using an Arduino UNO microcontroller and a dedicated stepper motor driver. The Arduino UNO generates the necessary control signals (direction and step pulses) to the stepper driver, which in turn drives the stepper motor. The motor is powered by a 12V battery, which also supplies power to the stepper driver. The system is intended to rotate the stepper motor in precise increments, both clockwise and counterclockwise.

Component List

Arduino UNO

Stepper Motor (Bipolar)

STEPPER DRIVER

12V Battery

Wiring Details

Arduino UNO

Stepper Motor (Bipolar)

STEPPER DRIVER

Documented Code

#include <AccelStepper.h>
#include <MultiStepper.h>

// Pin assignments
const int dirPin = 2;    // Direction pin
const int stepPin = 3;   // Pulse/Step pin
const int stepsPerRevolution = 200;  // For a 1.8-degree stepper motor (adjust as necessary)
const int stepsFor180Degrees = stepsPerRevolution / 2;  // 180 degrees = half of a full revolution

void setup() {
  // Set pins as outputs
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
}

void loop() {
  // Rotate motor clockwise 180 degrees
  digitalWrite(dirPin, HIGH);  // Set direction to clockwise
  for (int i = 0; i < stepsFor180Degrees; i++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(1000);  // Adjust delay for motor speed
    digitalWrite(stepPin, LOW);
    delayMicroseconds(1000);  // Adjust delay for motor speed
  }
  delay(1000);  // Pause for a second

  // Rotate motor counterclockwise 180 degrees
  digitalWrite(dirPin, LOW);  // Set direction to counterclockwise
  for (int i = 0; i < stepsFor180Degrees; i++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(1000);  // Adjust delay for motor speed
    digitalWrite(stepPin, LOW);
    delayMicroseconds(1000);  // Adjust delay for motor speed
  }
  delay(1000);  // Pause for a second
}

Filename: sketch.ino

Description: This code is designed to control a bipolar stepper motor via an Arduino UNO. It sets up the necessary digital pins as outputs and then enters a loop where it rotates the motor 180 degrees clockwise, waits for a second, then rotates it 180 degrees counterclockwise, and waits again. The delays between the steps can be adjusted to control the speed of the motor.