Arduino控制步进电机,但电机为何不转只会嗡嗡叫并震动?

michaelzim 2021-09-161370 次点击
为自动喂鱼食套件,才有网站提供的程序,但是步进电机只会嗡嗡响和震动,但是不会动。

程序代码如下:
```
//This adds the preexisting stepper library so you can use commands like "myStepper.setSpeed()" and "myStepper.step()"
#include <Stepper.h>

//This is the number of steps in one revolution of the motor. The 28BYJ-48 motor has 2048 steps per revolution. Make sure to find the number of steps of your motor.
const int stepsPerRevolution = 2048;

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

void setup() {‌‌
// set the speed at 10 rpm:
myStepper.setSpeed(50);
}

void loop() {‌‌
// 146 steps is 1/14th of a full rotation. Since I have 14 wells, this will index the feeder one space.
myStepper.step(146);
//This kills the power to the stepper to save energy and to keep it from heating up.
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
//This is the delay between feeding times. During testing I found it helpful to use 1 second to make sure it was rotating well.
delay(5000); //Pause for 5 seconds
//delay(28800000); //Pause for 8 Hours

//This section is the same as above but allows for a different delay time. After breakfast, it waits 8 hours until dinner time. Then it waits 16 hours until breakfast time.
myStepper.step(146);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
delay(5000); //Pause for 1 seconds
//delay(57600000); //Pause for 16 Hours


}
```
收藏 ♥ 感谢
Spoony 小组长 2021-09-17 
myStepper.setSpeed(1);
myStepper.step(2046);

代码中的参数改成上面这个试试。
RaspiSQH 117.6m 2021-09-20 
这个问题我遇到过,很多买来的步进电机的线序是乱的,所以得自己挨个试顺序😂

登录注册 后可回复。

这里由以下店铺的技术人员在此免费提供能力范围内的技术支持。

NXEZ 创客商店(淘宝)

排障问题发帖注意事项:
1、请尽可能将故障说明清晰,列明例如使用环境和做了哪些操作和配置等。
2、排障中已经做了哪些尝试,如果能在问题中进行描述将极大提高解决问题的效率。
3、对于需要自身完成知识积累才能解决的问题,请自行通过搜索引擎寻找资料学习。