hello everyone, I am using the elegoo uno r3 microcontroller from the set linked here (which I am assuming is mostly a reskinned version of the regular uno).
I have been trying to get my 5V 28BYJ-48 stepper motor working in combination with a ULN2003 driver board, but, well, see the title. I have attempted to follow the schematic attached exactly and after a few hours of constant checking I am certain that the wiring is correct.
I know this has been posted a couple of times in the past. I have tried the solution in this post where I switched up all permutations of the output pin arguments in the stepper constructor, but all of them result in the same vibrations (although the driver board leds shine differently). from what I have scraped from the internet it seems these usually mess up because of mismatched wire connections, but perhaps it could be something else. my power source is a 9V battery. here is the code that was provided:
#include <Stepper.h>
const int stepsPerRevolution = 2048; // change this to fit the number of steps per revolution
const int rolePerMinute = 15; // Adjustable range of 28BYJ-48 stepper is 0~17 rpm
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
void setup() {
myStepper.setSpeed(rolePerMinute);
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
// step one revolution in one direction:
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
delay(500);
// step one revolution in the other direction:
Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution);
delay(500);
}
I don't feel the motor getting hot or anything, but at this point I think there might even be something wrong with the chip/motor. if there are some measures you need me to take in order to test I'll be glad to, thanks a lot.
Try this code. Trim it backt to just Uno pins, vs Mega2560.
#include <Stepper.h> //include the function library, standard Arduino library
#define STEPS 64 // 64 steps per rev
Stepper stepper0(STEPS, 5, 3, 4, 2); //create the stepper0 <<< Order here is important
void setup()
{
}
void loop()
{
stepper0.setSpeed(120); //set speed to 10 rpm <<< this go in setup()?
stepper0.step(640); //move 360 deg one direction
delay(500); //pause for effect
stepper0.step(-640); //move 360 deg in the other direction
delay(500); //pause
}
With ULN2003 board, it needs Power/Gnd, then the 4 coil wires.
CrossRoads:
Try this code. Trim it backt to just Uno pins, vs Mega2560.
#include <Stepper.h> //include the function library, standard Arduino library
#define STEPS 64 // 64 steps per rev
Stepper stepper0(STEPS, 5, 3, 4, 2); //create the stepper0 <<< Order here is important
void setup()
{
}
void loop()
{
stepper0.setSpeed(120); //set speed to 10 rpm <<< this go in setup()?
stepper0.step(640); //move 360 deg one direction
delay(500); //pause for effect
stepper0.step(-640); //move 360 deg in the other direction
delay(500); //pause
}
With ULN2003 board, it needs Power/Gnd, then the 4 coil wires.
https://www.youtube.com/watch?v=S7PDCv7cb_4
hello crossroads,
thank you very much, I was finally able to see movement
I have two questions.
are the pins 2 3 4 5 different than 8 9 10 11? or did you move them for simplicity?
is this code meant to make 360 revolutions? in fact, mine is only moving about 1/8 of that.
EDIT: hello everybody, somehow I was able to fix it by setting STEPS to 64, the rotations to 2048, and the speed to 120? and it now makes a full revolution. well, it did at first. it is moving far slower than 10 rpm.
the motor is spinning to various degrees of slowness (I can see the leds on my driver getting really dim) to the point where it doesn't even move at all. I'm not sure if this is a weak battery or what, or maybe I accidentally produced some code that moves slower