Don't get step motor 28byj-48 running

Hello people,

After alot of research i ended here for my problem.
I have program experience but i know very little from electric things.
And becouse the standaard arduino code isn't working, i wonder what i did wrong.
The stepper motor isn't doin anything. Ony 1 red light is on, see the images.

I hope someone has a soluton for me:




#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);            

void setup() {
  // set the speed at 60 rpm:
  myStepper.setSpeed(60);
  // 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); 
}

This is the code of the standaard stepper_oneRevolution example.

Hi, there is an other tread by a different person with a similar problem.
I have the same stepper and driver board and I had trouble with the sketch you are using.
Try this code, I can't remember where I got it, I have moded it so that the value of val is set in the code and not by a potentiometer as it was originally intended.

/* 
 Stepper Motor Control - speed control
 
 This program drives a unipolar or bipolar stepper motor. 
 The motor is attached to digital pins 2 - 5 of the Arduino.
 A potentiometer is connected to analog input 0.
 
 The motor will rotate in a clockwise direction. The higher the potentiometer value,
 the faster the motor speed. Because setSpeed() sets the delay between steps.
 
 */


int IP1;
int IP2;
int IP3;
int IP4;
int val;
int ddelay;
int dddelay;

void setup() {
  // nothing to do inside the setup
  IP1=2;
  IP2=3;
  IP3=4;
  IP4=5;
  Serial.begin(9600);
  pinMode(IP1,OUTPUT);
  pinMode(IP2,OUTPUT);
  pinMode(IP3,OUTPUT);
  pinMode(IP4,OUTPUT);
}

void loop() {
//  val = analogRead(0);
val=1000;   //   Sets speed 0 to 1000
  ddelay = map(val, 0, 1006, 500, 3);
  dddelay =constrain(ddelay,3,500);
    Serial.print(dddelay);
    Serial.print("  ");
    Serial.println(val);
 
  digitalWrite(IP1, HIGH);
  digitalWrite(IP2, HIGH);
  digitalWrite(IP3, LOW);
  digitalWrite(IP4, LOW);
  delay(dddelay);
//   val = analogRead(0);
  ddelay = map(val, 0, 1006, 500, 3);
  dddelay =constrain(ddelay,3,500);
    Serial.print(dddelay);
    Serial.print("  ");
    Serial.println(val);
  digitalWrite(IP1, LOW);
  digitalWrite(IP2, HIGH);
  digitalWrite(IP3, LOW);
  digitalWrite(IP4, LOW);
  delay(dddelay);
//   val = analogRead(0);
  ddelay = map(val, 0, 1006, 500, 3);
dddelay =constrain(ddelay,3,500);
    Serial.print(dddelay);
    Serial.print("  ");
    Serial.println(val);
  digitalWrite(IP1, LOW);
  digitalWrite(IP2, HIGH);
  digitalWrite(IP3, HIGH);
  digitalWrite(IP4, LOW);
  delay(dddelay);
 //  val = analogRead(0);
  ddelay = map(val, 0, 1006, 500, 3);
  dddelay =constrain(ddelay,3,500);
    Serial.print(dddelay);
    Serial.print("  ");
    Serial.println(val);
  digitalWrite(IP1, LOW);
  digitalWrite(IP2, LOW);
  digitalWrite(IP3, HIGH);
  digitalWrite(IP4, LOW);
  delay(dddelay);
//   val = analogRead(0);
  ddelay = map(val, 0, 1006, 500, 3);
  dddelay=constrain(dddelay,3,500);
    Serial.print(ddelay);
    Serial.print("  ");
    Serial.println(val);
  digitalWrite(IP1, LOW);
  digitalWrite(IP2, LOW);
  digitalWrite(IP3, HIGH);
  digitalWrite(IP4, HIGH);
  delay(dddelay);
//   val = analogRead(0);
  ddelay = map(val, 0, 1006, 500, 3);
  dddelay=constrain(ddelay,3,500);
    Serial.print(dddelay);
    Serial.print("  ");
    Serial.println(val);
  digitalWrite(IP1, LOW);
  digitalWrite(IP2, LOW);
  digitalWrite(IP3, LOW);
  digitalWrite(IP4, HIGH);
  delay(dddelay);
//   val = analogRead(0);
  ddelay = map(val, 0, 1006, 500, 3);
  dddelay=constrain(ddelay,3,500);
    Serial.print(dddelay);
    Serial.print("  ");
    Serial.println(val);
  digitalWrite(IP1, HIGH);
  digitalWrite(IP2, LOW);
  digitalWrite(IP3, LOW);
  digitalWrite(IP4, HIGH);
  delay(dddelay);
//   val = analogRead(0);
  ddelay = map(val, 0, 1006, 500, 3);
  dddelay=constrain(ddelay,3,500);
    Serial.print(dddelay);
    Serial.print("  ");
    Serial.println(val);
  digitalWrite(IP1, HIGH);
  digitalWrite(IP2, LOW);
  digitalWrite(IP3, LOW);
  digitalWrite(IP4, LOW);
  delay(dddelay);
}

Note that I use pins 2 to 5, but you can change the code to use 8 to 11.

Tom..... :slight_smile:
PS note that this stepper has a gearbox in it so it will not turn very fast.

Hey Tom,

Thanks for your quick reply.

I uploaded this code and its still not working, also changed the code to pin 8-11 and changed the cables to 2-5.

I checked every cable to becouse i now think its a hardware problem.
Its hard to test where the problem is becouse the motor has to work with the 2003a thing(with the 4 leds)

Maybe another suggestion?

Hi, you don't have to have the stepper plugged in to see the driver working, the LEDs are connected to each output.
So, if they light up in a pulsing run then the stepper is being driven.

The code I supplied is already set up to 2 to 5, all you hand to do was move the wires n your project to pins 2 to 5.
If you changed my code to 8 to 11 and moved the wires to 2 to 5 then it won't work.

Tom..... :slight_smile:
PS, In your pictures I see one LED lit, is that all that happens?
You can do a basic test on the driver, take all the four control wires out of the arduino, then connect each one to the 5V pin on the arduino, that is you connect each input of the driver board to 5V, as you connect each to 5V the corresponding LED on the driver PCB should light up.

Because this problem seems to be identical with the other Thread I reckon it would be more useful for everyone if you asked the moderator to merge them.

I don't have the hardware you have, so may I make a suggestion for something to try ...

I would write a short sketch that just puts a HIGH output on one of the connections to the driver board and then measure the voltage across the relevant motor coil. Then do the same with a LOW output. Then move on to each of the other connections. This will allow you to satisfy yourself that power is getting to the motor coils. It would also be useful to measure the current in each coil.

Then you need to figure out the order in which the coils need to be energized to make the motor move. This document gives a lot of info about steppers. And then write some very simple code to generate a suitable series of outputs to give the right power sequence. At that stage you will probably know enough to figure out why the library code isn't working.

...R

Guys thank you so much for the replies.
I tried some things out and when i unplugged the step motor cable from the 2003a unit. When i unplugged it, the 4 leds are blinking as crazy as the should do. But when i plugin the motor, only the first led is on ( as you can see on the pictures i posted ).
Since i dont know alot about electricity, is it possible that the stepmotor isnt getting enough power?

My setup is the same as the pictures, only the inputs are on 2,3,4,5, just like the code Tom gave me.

Thanks !!