首页 > 解决方案 > 我尝试的代码无法运行 blcd 电机

问题描述

我正在使用 Arduino uno3 制作无控制无人机,并希望在其上运行 bldc 电机。我还提供了合适的电压电池。但是,电机根本不运行。

我什么都试过了。我在谷歌上找到的校准代码可以正常工作。该代码旨在将 int 值放入串行监视器中。我不使用串行监视器,所以我将一个 int 值作为 motor.writeMicroseconds 函数的参数传递。但它根本不起作用。我几乎尝试了一切,但失败了。我把正确的别针放在板上。但它仍然没有工作。

int MAX_SIGNAL 2000
int MIN_SIGNAL 1000 //signals
int MOTOR_PINA 9
int MOTOR_PINB 8
int MOTOR_PINC 7
int MOTOR_PIND 6

Servo motor1;
Servo motor2;
Servo motor3;
Servo motor4; //motorpin init

void setup() {
  Serial.begin(9600);
  motor1.attach(MOTOR_PINA,1000,2000);
  motor2.attach(MOTOR_PINB,1000,2000);
  motor3.attach(MOTOR_PINC,1000,2000);
  motor4.attach(MOTOR_PIND,1000,2000); //motor connect to board, set min,max speed 


  motor1.writeMicroseconds(MAX_SIGNAL);
  motor2.writeMicroseconds(MAX_SIGNAL);
  motor3.writeMicroseconds(MAX_SIGNAL);
  motor4.writeMicroseconds(MAX_SIGNAL);

  delay(100);
  motor1.writeMicroseconds(MAX_SIGNAL);
  motor2.writeMicroseconds(MAX_SIGNAL);
  motor3.writeMicroseconds(MAX_SIGNAL);
  motor4.writeMicroseconds(MAX_SIGNAL);
  //calibration
}

void loop() {

    int DELAY = 1200;
    motor1.writeMicroseconds(DELAY);      
    motor2.writeMicroseconds(DELAY);      
    motor3.writeMicroseconds(DELAY);      
    motor4.writeMicroseconds(DELAY);    
    delay(1000);    
}

没有错误消息。但电机不运转。

标签: arduino

解决方案


推荐阅读