Simple Stepper Motor

Introduction

are used in a variety of different projects, and understanding how to set up different motortypes is essential to being successful with mechatronic prototyping.

In this guide you will learn how to create a simple setup.

Before continuing this guide it is recommended that you have read- or have basic knowledge about .

Supplies

Circuit

The circuit created in TinkerCAD
Micro steppers usually need a motor-driver to control them accurately. In most beginner kits there is both a driver and a stepper motor. To create the circuit, one needs to connect the four different IN-pins from the motor driver to four different pins on the . Additionally, the power pins (+/-) from the driver needs to be connected to a 5V pin (+) and GND (-).

Code

// Simple servo motor setup

// This code will make your servo scan from 0 to 180 degrees and back again

// Servo library imported
#include <Servo.h>

// initialize pin used to communicate to servo
const int servoPin = 9;

// initialize a servo from the library Servo.h
Servo servo;

// variable initialized that is used to dictate
// servo angle
int angle = 0; // servo position in degrees

void setup() {
    // tell the servo to get input from servoPin
    // (which was initialized to pin 9)
    servo.attach(servoPin);
}

void loop() {
    // scan from 0 to 180 degrees
    for (angle = 0; angle < 180; angle++) {
        servo.write(angle);
        delay(15);
    }

    // now scan back from 180 to 0 degrees
    for (angle = 180; angle > 0; angle--) {
        servo.write(angle);
        delay(15);
    }
}

Further Work

Now that you have completed this guide on how to use servo motors in a simple manner, you can try to 3D print a small model that can be attached to the servo by following the guide on how to .