This library allows you to control unipolar or bipolar stepper motors. To use it you will need a stepper motor, and the appropriate hardware to control it. For more on that, see Tom Igoe's notes on steppers.
函数
Stepper(steps, pin1, pin2)步进电机定义
Stepper(steps, pin1, pin2, pin3, pin4)步进电机定义
Description 解释
This function creates a new instance of the Stepper class that represents a particular stepper motor attached to your Arduino board. Use it at the top of your sketch, above setup() and loop(). The number of parameters depends on how you've wired your motor - either using two or four pins of the Arduino board.
Parameters 参数
steps: the number of steps in one revolution of your motor. If your motor gives the number of degrees per step, divide that number into 360 to get the number of steps (e.g. 360 / 3.6 gives 100 steps). (int) 一圈对应的步数
pin1, pin2: two pins that are attached to the motor (int)
pin3, pin4: optional the last two pins attached to the motor, if it's connected to four pins (int)
Returns A new instance of the Stepper motor class.
速度设定
Description 解释
Sets the motor speed in rotations per minute (RPMs). This function doesn't make the motor turn, just sets the speed at which it will when you call step().
Parameters 参数
rpms: the speed at which the motor should turn in rotations per minute - a positive number (long)
Returns None 无返回值
step(steps)步数执行
Description
Turns the motor a specific number of steps, at a speed determined by the most recent call to setSpeed(). This function is blocking; that is, it will wait until the motor has finished moving to pass control to the next line in your sketch. For example, if you set the speed to, say, 1 RPM and called step(100) on a 100-step motor, this function would take a full minute to run. For better control, keep the speed high and onl