To test out our current limiting stepper driver, we'll use the standard Arduino Stepper library. This is included with the Arduino IDE, so no additional libraries need to be installed.
Copy the code below and upload it to your Arduino.
#include <Stepper.h> // A 200-step motor connected on pins 2-5 Stepper stepper(200, 2,3,4,5); void setup() { // Rotate at 20 rpm: stepper.setSpeed(20); Serial.begin(9600); Serial.println("Stepper Test!"); } void loop() { // Step forward 1000 steps Serial.println("forward"); stepper.step(1000); // Step in reverse 1000 steps Serial.println("backward"); stepper.step(-1000); }
The motor should start turning back and forth - 1000 steps at a time.
Text editor powered by tinymce.