Trying to debug first build with Unipolar motor and supplied controller

Still trying to debug this. Motor is 28BYJ-48 5v. Controller is referred to as ULN2003, but it is a board, not just an IC chip.


Pins 1,2,3,4 on the motor controller go to pins 8,9,10,11 on my Mega board. I've seen instructions with those wires reversed. Neither option works. If I comment out "If Serial.available()>0" I can get it to print stuff to my IDE. Lights are on, but the motor is not turning. Motor got hot at one point. I switched to another motor of the same make, still no motion. HELP. Also, on the motor controller, all examples I see show putting the power wires into the 5v side, but my board will not light up unless I use the 12v side.

#include <Stepper.h>

const int stepsPerRevolution = 2038;

Stepper stepper (stepsPerRevolution, 8,10,9,11);

int val=0;

void setup() {

// put your setup code here, to run once:

Serial.begin(9600);

stepper.setSpeed(2);

Serial.println("Did I get this far?");

}

void loop() {

// put your main code here, to run repeatedly:

Serial.println(val);

if(Serial.available()>0)

{
  
  val = Serial.parseInt();
  
  stepper.step(val);
  
  Serial.println(val);
  
  Serial.println("Am I looping?");
  
  }

}

And then I tried this and still getting nothing:

#include <Stepper.h>
const  int stepsPerRevolution = 2038;
Stepper stepper (stepsPerRevolution, 8,10,9,11);
int val=1024;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  stepper.setSpeed(60);
  Serial.println("Did I get this far?");
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println(val);
  //if(Serial.available()>0)
  //{
    //val = Serial.parseInt();
    stepper.step(val);
    Serial.println(val);
    Serial.println("Am I looping?");

  //}
}

You need to use a separate 5-volt supply. You should never power a motor directly from an Arduino.

This article may prove to be useful.

1 Like

Do you know why "if(Serial.available)() >0" is there in the program? It is there so you enter the parameters for the stepper motor. When testing, did you enter the values on your PC so they could be transferred to the Arduino and let the stepper work.

Your motor has 64 steps per revolution. Where did you get 2038?

The motor has in integrated gear box, which makes it about 2048 steps/rev.
Leo..

where do I enter the parameters on the pc?

You turn on the serial monitor part of the IDE, your development system. By the way, my introduction to Arduino used the same stepper and program as you are using and it runs just fine with the direct connections to the Arduino. No external power needed for this motor.

1 Like

I tried powering it from this item, and it gets no power. Other examples I see on the web show it powering from the Arduino, but I'm also using an AC to DC 9v converter to power the other port on the Arduino. But, I could be wrong in what I'm doing.

This is what I see on the Serial Monitor. There is an input field at the top, but what do I input there to send to the arduino?

That motor draws about 350mA.
A breadboard supply powered with 9volt input would struggle (getting hot) to deliver that current.
Stick with powering the motor directly from the Mega (on USB supply).
Leo..

I entered a value in the Serial monitor, but no movement. It prints out what I entered, but that's it.

My other pertinent question is, on the controller board, why does it only power when I pin into the 12v side. It won't power from the 5v side, though I see examples where it does that.

Which board do you have. My board does not have a 12volt or 5volt pin.
The + pin is just labled 5-12volt.
Did you leave the jumper on?
Your image shows all the LEDs lit. They only should light up/flash when stepping.
Leo..

The controller board does not really have a name on it. It came with the Mega kit. It has MCU 10 down in one corner, but I'm thinking that's not a name. It does just say 5-12v. I switched the jumper over to the left side, and it started lighting up. But everything is lit from the start, before I kick off the program.

Ok, I removed the power supply from the Mega (but not the USB) and the controller did not light until I typed in '2044' in the Serial Monitor field. It looped the code twice, once showing "1", then once showing "0", then stopped looping. The motor did not move, but pins 1 and 2 on the controller stayed lit. I see code giving the stepper module pins 8, 9, 10, 11, but I see others giving pins parameters of 8, 10, 9, 11, and that is what I'm using.

Should be ok. This will also enable the motor to move backwards.
8,9,10,11 only works forwards.

Try to move the motor by hand, and see if it's not stuck mechanically.
You will need a bit of force to do this. Maybe even have to use pliers.
Leo..

Success. Found something on another site of someone who debugged this problem.
He changed the speed rate to something under 15.

#include <Stepper.h>
const  int stepsPerRevolution = 2038;
Stepper stepper (stepsPerRevolution, 8,10,9,11);
int val=0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  stepper.setSpeed(10);
  //Serial.println("Did I get this far?");
}

void loop() {
  // put your main code here, to run repeatedly:
  //Serial.println(val);

  if(Serial.available()>0)
  {
    Serial.println(Serial.available());
    val = Serial.parseInt();
    stepper.step(val);
    Serial.println(val);
    //Serial.println("Am I looping?");

  }
}

Sorry, missed that. These motors only do about 12RPM.
Leo..

Thank you for trying.