source: arduino-1-6-7/trunk/fuentes/arduino-ide-amd64/libraries/Stepper/examples/stepper_oneRevolution/stepper_oneRevolution.ino @ 46

Last change on this file since 46 was 46, checked in by jrpelegrina, 4 years ago

First release to Xenial

File size: 995 bytes
Line 
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
20const 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:
24Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
25
26void setup() {
27  // set the speed at 60 rpm:
28  myStepper.setSpeed(60);
29  // initialize the serial port:
30  Serial.begin(9600);
31}
32
33void 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
Note: See TracBrowser for help on using the repository browser.