Jika Anda mampu membelinya, dan Anda benar-benar ingin bekerja dengan stepper super mudah, periksa Easy Stepper . Saya sangat senang.
Dari halaman contoh kode
http://www.sc-fa.com/blog/wp-content/uploads/2013/04/20130414-080645.jpg
Example 1: Basic Arduino setup
This is the most basic example you can have with an Arduino, an Easy Driver, and a stepper motor. Connect the motor's four wires to the Easy Driver (note the proper coil connections), connect a power supply of 12V is to the Power In pins, and connect the Arduino's GND, pin 8 and pin 9 to the Easy Driver.
Then load this sketch and run it on your Arduino or chipKIT:
void setup() {
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
}
void loop() {
digitalWrite(9, HIGH);
delay(1);
digitalWrite(9, LOW);
delay(1);
}
Juga dari halaman yang sama, inilah beberapa contoh kode untuk menjalankan dua motor dengan dua papan easystepper, dengan akselerasi / perlambatan:
http://www.sc-fa.com/blog/wp-content/uploads/2013/04/20130414- 081018.jpg
#include <AccelStepper.h>
// Define two steppers and the pins they will use
AccelStepper stepper1(1, 9, 8);
AccelStepper stepper2(1, 7, 6);
int pos1 = 3600;
int pos2 = 5678;
void setup()
{
stepper1.setMaxSpeed(3000);
stepper1.setAcceleration(1000);
stepper2.setMaxSpeed(2000);
stepper2.setAcceleration(800);
}
void loop()
{
if (stepper1.distanceToGo() == 0)
{
delay(500);
pos1 = -pos1;
stepper1.moveTo(pos1);
}
if (stepper2.distanceToGo() == 0)
{
delay(500);
pos2 = -pos2;
stepper2.moveTo(pos2);
}
stepper1.run();
stepper2.run();
}