// 2010 mlab.taik.fi/paja // Controlling stepper motor // Miniture stepper motor from Symbol technology // "21-02485-03" - 18 degree step motor // This code is created based on the example from Motor Shield website // http://www.ladyada.net/make/mshield/ #include // 1st argument: steps. e.g. 18 degree step motor -> 360/18 = 20 steps. // 2nd argument: port number. Motor connected to M1 and M2 uses 1. M3 and M4 goes to 2. AF_Stepper motor(20, 2); void setup() { } void loop() { // 1st: Unit of speed is RPM (Revolutions per minute). motor.setSpeed(200); // 1st: number of steps // 2nd: direction // 3rd: Step type "'Single' means single-coil activation, // 'double' means 2 coils are activated at once (for higher // torque) and 'interleave' means that it alternates between // single and double to get twice the resolution (but of course // its half the speed). "Microstepping" is a method where the // coils are PWM'd to create smooth motion between steps." motor.step(20, FORWARD, DOUBLE); delay(1000); motor.setSpeed(20); motor.step(20, BACKWARD, DOUBLE); delay(1000); }