I am trying to vary the speed for a brushless motor that comes with a built-in driver using an Arduino UNO. This is the motor
The power lines are plugged to an external battery and the blue line to pin 6, the code is
int motor1_pin = 6;
void setup() {
pinMode(motor1_pin, OUTPUT);
}
void loop() {
analogWrite(motor1_pin, 255);
delay(1000);
analogWrite(motor1_pin, 127);
delay(1000);
analogWrite(motor1_pin, 0);
delay(500);
}
Currently the motor turns on and off but the speed isn't changing. Any guidance on how to work with this type of motor will be appreciated, thanks.
mfariasn:
void loop() {
analogWrite(motor1_pin, 255);
delay(1000);
analogWrite(motor1_pin, 127);
delay(1000);
analogWrite(motor1_pin, 0);
delay(500); * /
digitalWrite(motor1_pin, LOW);
delay(1000);
digitalWrite(motor1_pin, HIGH);
delay(1000);
}
HIGH and LOW are boolean variables and should not be used this way.
You need to operate the direction. Use a "dirPin", a second output and set it LOW or HIGH in the code.
Your link goes to a sales site, not a real datasheet. I don't see what the Yellow line: FG signal line is used for.
Thanks for a well posted question showing code and a link.
Do you have the negative of the motor common to the Arduino negative and supply.?
I believe the yellow wire is a pulse generated as the motor rotates.
No, the neg of the motor just goes to the neg of the battery, should I also put it to the Arduino?
This was the solution!! I put the Arduino, the motor and the battery on a common ground and now its working!!
system
Closed
September 7, 2022, 2:49am
8
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.