Project

General

Profile

Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (1.17 KB)

1

    
2
/* 
3
 Stepper Motor Control - one step at a time
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 will step one step at a time, very slowly.  You can use this to
9
 test that you've got the four wires of your stepper wired to the correct
10
 pins. If wired correctly, all steps should be in the same direction.
11
 
12
 Use this also to count the number of steps per revolution of your motor,
13
 if you don't know it.  Then plug that number into the oneRevolution
14
 example to see if you got it right.
15
 
16
 Created 30 Nov. 2009
17
 by Tom Igoe
18
 
19
 */
20

    
21
#include <Stepper.h>
22

    
23
const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
24
                                     // for your motor
25

    
26
// initialize the stepper library on pins 8 through 11:
27
Stepper myStepper(stepsPerRevolution, 8,9,10,11);            
28

    
29
int stepCount = 0;         // number of steps the motor has taken
30

    
31
void setup() {
32
  // initialize the serial port:
33
  Serial.begin(9600);
34
}
35

    
36
void loop() {
37
  // step one step:
38
  myStepper.step(1);
39
  Serial.print("steps:" );
40
  Serial.println(stepCount);
41
  stepCount++;
42
  delay(500);
43
}
44