arduino步进电机程序库_步进电机的Arduino库函数

本文介绍了如何使用Arduino库控制步进电机,包括库的函数用法,如Stepper函数用于定义步进电机,setSpeed函数设置电机速度,step函数执行指定步数。提供了多个示例,如用电位器控制步进电机速度和步数,帮助理解步进电机的工作原理和编程方法。
摘要由CSDN通过智能技术生成

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值