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

Arduino UNO Controlled Stepper Motor and Servo System

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled Stepper Motor and Servo System

Circuit Documentation

Summary

This circuit involves an Arduino UNO microcontroller controlling a stepper motor and a micro servo. The Arduino UNO provides the necessary control signals to drive the stepper motor and the servo motor, enabling precise movement control.

Component List

Stepper Motor One

Arduino UNO

Micro Servo 9G

Wiring Details

Stepper Motor One

Arduino UNO

Micro Servo 9G

Documented Code

#include <Stepper.h>
#include <Servo.h>

#define OUTPUT1   4
#define OUTPUT2   5
#define OUTPUT3   6
#define OUTPUT4   7

Servo servo;
const int stepsPerRotation = 2048; // 
Stepper myStepper(stepsPerRotation, OUTPUT1, OUTPUT3, OUTPUT2, OUTPUT4);  

void setup() {
  servo.attach(8);
  servo.write(90);
  myStepper.setSpeed(15); // RPM (Round Per Minute)
}

void loop() {
  myStepper.step(stepsPerRotation);
  delay(500);
  servo.write(0);
  delay(500);
  myStepper.step(-stepsPerRotation);
  delay(500);
  servo.write(180);
  delay(500);
}

This code initializes the stepper motor and the servo motor. In the setup function, the servo is attached to pin 8 and set to a neutral position (90 degrees). The stepper motor speed is set to 15 RPM. In the loop function, the stepper motor rotates one full rotation in one direction, pauses, then rotates one full rotation in the opposite direction, with the servo moving between 0 and 180 degrees in between each stepper motor movement.