PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
libArduino
tests
StepperOneRev
StepperOneRev.cpp
1
/*
2
Stepper Motor Control - one revolution
3
4
This program drives a unipolar or bipolar stepper motor.
5
The motor is attached to digital pins 8 - 11 of the Arduino.
6
7
The motor should revolve one revolution in one direction, then
8
one revolution in the other direction.
9
10
11
Created 11 Mar. 2007
12
Modified 30 Nov. 2009
13
by Tom Igoe
14
15
*/
16
17
#include <Arduino.h>
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
30
// initialize the serial port:
31
Serial.begin(9600);
32
}
33
34
void
loop() {
35
// step one revolution in one direction:
36
Serial.println(
"clockwise"
);
37
myStepper.step(stepsPerRevolution);
38
delay(500);
39
40
// step one revolution in the other direction:
41
Serial.println(
"counterclockwise"
);
42
myStepper.step(-stepsPerRevolution);
43
delay(500);
44
}
Stepper
Definition:
Stepper.h:49
Generated on Fri May 20 2022 16:48:01 for PropWare by
1.8.17