If statement not being executed

What you go on to describe isn't "working".

Yes, a power problem, but yes, you are never going to run it connected directly.

Can you test the Arduino boards to make sure you haven't damaged them? Just see if those pins can (still) make an LED turn on and off.

With the controller, it sounds like you got some wires crossed somewhere, so check that while we try to with you pictures.

What is the actual source for the 5 volts? How is the Arduino boad getting its 5 volts?

a7

Did you read this? I'm on the small window, but you need to say you have accounted for this:

// To get the correct step sequence, we need to set the pins in the following order: 8, 10, 9, 11.

// Create stepper object called 'myStepper', note the pin order:
Stepper myStepper = Stepper(stepsPerRevolution, 8, 10, 9, 11);

which would crtnly qualify as crossing wires…

a7

Yes. I have tried crossing the wires and connecting it in order. Right now the arduino is powered off usb to my computer and the motor controller is powered through an AC-DC power supply that outputs 5V-2.1A. That should be an excessive amount of current for it to draw from but I also tried an AC-DC power supply that outputs 5V-550mA as the motor controller shouldn't be drawing more than than half that amount.

I thought I solved my problem last night when I found this helpful thread:

However after reading through it and trying all the different suggestions and uploading any code listed or linked to I still got absolutely no movement.

I just tried moving the motor controller out of pins 8-11 to see if I did destroy those pins but still nothing on pins 3-6. When doing this I tried it sequentially along with plugging it 3,5,4,6.
This is the code I just tried that with in order to see if I could get the stupid motor to move at all:


/*
 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

 */

#include <Stepper.h>

const int stepsPerRevolution = 2038;  // 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, 3, 4, 5, 6);

void setup() {
  // set the speed at 60 rpm:
  myStepper.setSpeed(5);
  // 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 also can in fact make an LED light up with my switch on pins 8-11.

Maybe the motor gods just hate me

Did you try this order for the constructor?
Stepper myStepper(stepsPerRevolution, 3, 5, 4, 6);

I think it might be time for you to verify all the coil leads and where they go on your motor. Which colors actually go where?

https://www.utmel.com/components/28byj-48-5v-stepper-motor-28byj-48-datasheet-pinout-wiring?id=1294

I have tried changing the order for the constructor (though I restored everything to how it was once I verified 8-11 were still working so 8,10,9,11). Still nothing just a lot of heat.

I've looked at the data sheet and the pin out listed in the link and I believe they're different.
The Data Sheet says its wired
1-Blue
2-Pink
3-Yellow
4-Orange
5-Red

Which is exactly how my motor is set up.


Note it’s unplugged here because the LEDs make it hard to photograph

The pinout in the link says
1-Orange
2-Pink
3-Yellow
4-Blue
5-Red

The wires in the molex do go directly to the outputs on the board so that 1 goes to IN1 and so on with 5 going to power.
I just tried taking the outputs to the Nano and rearranging them so that they matched the second pin out and had no luck either.
Lastly I just tried restoring the cables and changing it in the code to match that second pinout (11,9,10,8) and had no luck either.

The other thing that worries me is the LEDs on the motor driver are not changing like its going through the steps but it would be insanely weird to have two dead motor drivers out of the box, correct?

1 Like

Let us hope. Although if they came out of the same box…

Do the LEDs on the control board work when you have no motor hooked up? Are they supposed to,just mirror the input lines?

It is also possible you killed them both yourself. These add-on boards are usually very forgiving, I've gotten away with some serious mistakes in wiring, but they can and do get damaged sometimes.

a7

They came from a friends apartment so who know if they came together but the one I've been doing all the troubleshooting on now was still sealed in plastic so I figured that was my best hope at a functioning board. Said friend said neither had been used though.

I absolutely agree I could have destroyed them both. I know for a fact though that at no point did I ever send more than 5 volts to it and it's also variable and can accept up to 12 volts in. I've also been metering before I connected anything. Nothing smells like that electronic burning smell and at no time did either overheat. The only thing to get hot was the motor itself.

The LEDs do work on motor driver as long as it has power and is connected with the arduino. The minute you pull a wire the LED goes off.
On this it says that they're suppose to reflect the step state of which channel is active.

If you disconnect the motor and just use digitalWrite( ) HIGH/LOW on each of the individual leads from the arduino, can you turn the individual leds on and off?

EDIT: Have you verified that the motor wiring is correct, and that the proper colored wires make up the correct coils according to the data sheet.

In the other (closed) thread you wrote

I went back to basics and connected the motor directly to the board and uploaded a basic stepper code and got the motor to move back and forth.

/*
 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

 */

#include <Stepper.h>

const int stepsPerRevolution = 200;  // 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, 9, 10, 11);
…

So what’s your exact issue? Why don’t you just stick to the config that is working?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.