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
- board
- Wires
- Micro stepper motor
- Stepper motor driver
Circuit
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 .