Hi, can someone please help me with this issue?
Issues:
- When the motor rate inside setSpeed() is around 5, the motor runs successfully. But as I increased it to 7 or 8, the movement starts to get bumpy and there are intermittent brakes. When the rate is set to 10, the motor stops and only vibrates.
- Another problem is that the motor keeps on going the same direction after completing one full round of revolution (it's coded to go to the opposite direction after 1 revolution).
Setup:
- Arduino UNO r3.
- Stepper motor: 28BYJ-48.
- 9V battery.
Code:
#include <Stepper.h>
int stepsPerRevolution=2048;
int motor_rate=5;
//IN1, IN2, IN3, and IN4 are connected to pin 8,9,10, and 11 respectively.
Stepper myStepper(stepsPerRevolution, 8,9,10,11);
void setup() {
// put your setup code here, to run once:
myStepper.setSpeed(motor_rate);
}
void loop() {
// put your main code here, to run repeatedly:
myStepper.step(stepsPerRevolution);
delay(500);
myStepper.step(-stepsPerRevolution);
delay(500);
}