Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/adafruit/Adafruit-Motor-Shield-library.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'examples/StepperTest/StepperTest.pde')
-rw-r--r--examples/StepperTest/StepperTest.pde36
1 files changed, 36 insertions, 0 deletions
diff --git a/examples/StepperTest/StepperTest.pde b/examples/StepperTest/StepperTest.pde
new file mode 100644
index 0000000..1ed94c5
--- /dev/null
+++ b/examples/StepperTest/StepperTest.pde
@@ -0,0 +1,36 @@
+// Adafruit Motor shield library
+// copyright Adafruit Industries LLC, 2009
+// this code is public domain, enjoy!
+
+#include <AFMotor.h>
+
+// Connect a stepper motor with 48 steps per revolution (7.5 degree)
+// to motor port #2 (M3 and M4)
+AF_Stepper motor(48, 2);
+
+void setup() {
+ Serial.begin(9600); // set up Serial library at 9600 bps
+ Serial.println("Stepper test!");
+
+ motor.setSpeed(10); // 10 rpm
+}
+
+void loop() {
+ Serial.println("Single coil steps");
+ motor.step(100, FORWARD, SINGLE);
+ motor.step(100, BACKWARD, SINGLE);
+
+ Serial.println("Double coil steps");
+ motor.step(100, FORWARD, DOUBLE);
+ motor.step(100, BACKWARD, DOUBLE);
+
+ Serial.println("Interleave coil steps");
+ motor.step(100, FORWARD, INTERLEAVE);
+ motor.step(100, BACKWARD, INTERLEAVE);
+
+#ifdef MICROSTEPPING
+ Serial.println("Micrsostep steps");
+ motor.step(100, FORWARD, MICROSTEP);
+ motor.step(100, BACKWARD, MICROSTEP);
+#endif
+}