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

Arduino-Controlled Dual Stepper Motor System with Bluetooth Interface

View and Edit Project In Cirkit DesignerImage of Arduino-Controlled Dual Stepper Motor System with Bluetooth Interface

Circuit Documentation

Summary

This circuit is designed to control two 28BYJ-48 stepper motors using an Arduino UNO microcontroller and two ULN2003A breakout boards. The circuit also includes an HC-06 Bluetooth module for wireless communication, allowing the motors to be controlled via Bluetooth commands. The Arduino UNO is programmed to interpret the Bluetooth commands and drive the stepper motors accordingly.

Component List

Arduino UNO

28BYJ-48 Stepper Motor (x2)

HC-06

ULN2003A Breakout Board (x2)

Wiring Details

Arduino UNO

28BYJ-48 Stepper Motor

HC-06

ULN2003A Breakout Board

Documented Code

#include <AccelStepper.h>

// Define the pins for motor 1 
AccelStepper motor1(AccelStepper::HALF4WIRE, 8, 10, 9, 11);

// Define the pins for motor 2
AccelStepper motor2(AccelStepper::HALF4WIRE, 4, 6, 5, 7);

// Set initial rotation speed
const int rotationSpeed = 500; 

void setup() {
  // Set up the serial communication for Bluetooth
  Serial.begin(9600);

  motor1.setMaxSpeed(rotationSpeed);
  motor1.setAcceleration(500);
  motor1.setCurrentPosition(0);

  motor2.setMaxSpeed(rotationSpeed);
  motor2.setAcceleration(500);
  motor2.setCurrentPosition(0);
}

void loop() {
  // Check if data is available from the Bluetooth app
  if (Serial.available() > 0) {
    char command = Serial.read();

    // Write commands for the app
    switch (command) {
      case 'F':  // Start both motors rotating forward
        motor1.setSpeed(rotationSpeed);
        motor2.setSpeed(rotationSpeed);
        motor1.enableOutputs();
        motor2.enableOutputs();
        break;
      case 'B':  // Start both motors rotating backward
        motor1.setSpeed(-rotationSpeed);
        motor2.setSpeed(-rotationSpeed);
        motor1.enableOutputs();
        motor2.enableOutputs();
        break;
      case 'S':  // Stop and disconnect both motors
        motor1.setSpeed(0);       // Set speed to 0 to stop immediately
        motor2.setSpeed(0);       // Set speed to 0 to stop immediately
        motor1.disableOutputs();  // Disable outputs to disconnect motors
        motor2.disableOutputs();  // Disable outputs to disconnect motors
        break;
      default:
        // Ignore any other commands
        break;
    }
  }

  // Run motors
  motor1.runSpeed();
  motor2.runSpeed();
}

The code above is written for the Arduino UNO and is responsible for controlling two stepper motors via the ULN2003A breakout boards. It includes a Bluetooth communication setup to receive commands and control the motors accordingly. The AccelStepper library is used to facilitate the control of the stepper motors.