source: rtos_arduino/trunk/arduino_lib/libraries/Stepper/examples/stepper_oneStepAtATime/stepper_oneStepAtATime.ino@ 136

Last change on this file since 136 was 136, checked in by ertl-honda, 8 years ago

ライブラリとOS及びベーシックなサンプルの追加.

File size: 1.1 KB
Line 
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
23const 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:
27Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
28
29int stepCount = 0; // number of steps the motor has taken
30
31void setup() {
32 // initialize the serial port:
33 Serial.begin(9600);
34}
35
36void loop() {
37 // step one step:
38 myStepper.step(1);
39 Serial.print("steps:" );
40 Serial.println(stepCount);
41 stepCount++;
42 delay(500);
43}
44
Note: See TracBrowser for help on using the repository browser.