(I am using the Elegoo 5V 28BYJ-48 motor)
(I am also using the Stepper library)
So basically I am using a stepper motor to spin and I want to increase the speed to about 50 RPM-ish. I don't know if this is a motor problem or a code problem. If I change the myStepper.setSpeed() or stepsPerRevolution to a higher amount, the stepper motor driver module blinks red and the stepper motor does not move. I do not know what is the cause.
Here is the code (The code is not entirely mine, I found this and then edited it)
// Stepper - Version: Latest
#include <Stepper.h>
/*
Stepper Motor Control - one revolution
This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.
The motor should revolve one revolution in one direction, then
one revolution in the other direction.
Created 11 Mar. 2007
Modified 30 Nov. 2009
by Tom Igoe
*/
const int stepsPerRevolution = 900; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(45);
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
// step one revolution in one direction:
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
delay(10);
}
Top speed for a 28BYJ-48 is about 13 RPM, steps per revolution is about 2048.
// Stepper - Version: Latest
#include <Stepper.h>
/*
Stepper Motor Control - one revolution
This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.
The motor should revolve one revolution in one direction, then
one revolution in the other direction.
Created 11 Mar. 2007
Modified 30 Nov. 2009
by Tom Igoe
*/
const int stepsPerRevolution = 2048; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
void setup() {
// set the speed at 12 rpm:
myStepper.setSpeed(12);
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
// step one revolution in one direction:
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
delay(1000);
}