StepperMotor \ Learning \ Wiring ALPHA 1.0
Author: Hernando Barragán
Description: Wiring is an electronic sketchbook and hardware electronics for developing ideas. It is a context for learning fundamentals of computer programming and prototyping with electronics within the context of the electronic arts.
Keywords: Wiring, Processing, Interactive Media, Electronic Arts, Programming, C, C++, Hernando Barragán

Search wiring.org.co:

This example is for Wiring version 0023+. If you have a previous version, use the examples included with your software. If you see any errors or have comments, please let us know.

Stepper Motor Sequences by Juan Manuel Gonzalez V.
Demonstrates the use of a TEAC stepper motor using pin commands. TEAC motors rotate 360 degrees in 50 cycles (steps).

    void setup()
    {
      int i;
      for(i=0; i<3; i++) {     //Analog pins for yellow, red,
        pinMode(i, OUTPUT);    //blue and white wires of the motor.
      }

      pinMode(48, OUTPUT);     //Wiring led pin 48.
      digitalWrite(48, HIGH);
    }

    void stepforward()         //Drive sequence for one cycle going
    {                          //forward.
      digitalWrite(0, HIGH);
      digitalWrite(1, LOW);
      digitalWrite(2, LOW);
      digitalWrite(3, LOW);
      delay(30);
      digitalWrite(0, LOW);
      digitalWrite(1, HIGH);
      digitalWrite(2, LOW);
      digitalWrite(3, LOW);
      delay(30);
      digitalWrite(0, LOW);
      digitalWrite(1, LOW);
      digitalWrite(2, HIGH);
      digitalWrite(3, LOW);
      delay(30);
      digitalWrite(0, LOW);
      digitalWrite(1, LOW);
      digitalWrite(2, LOW);
      digitalWrite(3, HIGH);
      delay(30);
    }

    void stepbackward()            //Drive sequence for one cycle going
    {                              //backward.
      digitalWrite(0, LOW);
      digitalWrite(1, LOW);
      digitalWrite(2, LOW);
      digitalWrite(3, HIGH);
      delay(30);
      digitalWrite(0, LOW);
      digitalWrite(1, LOW);
      digitalWrite(2, HIGH);
      digitalWrite(3, LOW);
      delay(30);
      digitalWrite(0, LOW);
      digitalWrite(1, HIGH);
      digitalWrite(2, LOW);
      digitalWrite(3, LOW);
      delay(30);
      digitalWrite(0, HIGH);
      digitalWrite(1, LOW);
      digitalWrite(2, LOW);
      digitalWrite(3, LOW);
      delay(30);
    }

    void loop()
    {
      stepforward();  //Repeats the required sequence over &
      //over to make the motor turn continuously FW.
      //stepbackward();        //Repeats the required sequence over &
      //over to make the motor turn continuously BW.
    }