Statistics
| Branch: | Revision:

root / arduino-1.0 / libraries / Stepper / examples / stepper_oneRevolution / stepper_oneRevolution.ino @ 58d82c77

History | View | Annotate | Download (1.03 KB)

1

    
2
/* 
3
 Stepper Motor Control - one revolution
4
 
5
 This program drives a unipolar or bipolar stepper motor. 
6
 The motor is attached to digital pins 8 - 11 of the Arduino.
7
 
8
 The motor should revolve one revolution in one direction, then
9
 one revolution in the other direction.  
10
 
11
  
12
 Created 11 Mar. 2007
13
 Modified 30 Nov. 2009
14
 by Tom Igoe
15
 
16
 */
17

    
18
#include <Stepper.h>
19

    
20
const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
21
                                     // for your motor
22

    
23
// initialize the stepper library on pins 8 through 11:
24
Stepper myStepper(stepsPerRevolution, 8,9,10,11);            
25

    
26
void setup() {
27
  // set the speed at 60 rpm:
28
  myStepper.setSpeed(60);
29
  // initialize the serial port:
30
  Serial.begin(9600);
31
}
32

    
33
void loop() {
34
  // step one revolution  in one direction:
35
   Serial.println("clockwise");
36
  myStepper.step(stepsPerRevolution);
37
  delay(500);
38
  
39
   // step one revolution in the other direction:
40
  Serial.println("counterclockwise");
41
  myStepper.step(-stepsPerRevolution);
42
  delay(500); 
43
}
44