Go Down

Topic: 28BYJ-48 Motor & ULN2003APG Driver Beginner (Read 5019 times) previous topic - next topic

AntSeniorProject

Nov 16, 2019, 03:22 am Last Edit: Nov 21, 2019, 03:45 am by AntSeniorProject Reason: Solved Issue, explanation provided
Issue has been solved. After poking around with a multimeter we found that there was consistent interuptions in the power and digital signal pulses. It turns out that the connecting pins on the driver, pinouts of the arduino, and the wires were all very tempermental. After securing all wires and applying pressure with the tension of tape, the driver leds lit up and the motor began to turn.

In short, inspect all hardware and connections. I now am aware of the importance of securing connections, and testing all leads with a multimeter

Hello,

I'm new to using Arduino and have been having consistent issues using the 28BYJ-48 and ULN2003APG Motor/Driver combination. My lab partner and I have searched countless YouTube videos, reread the steps on tutorials, and read through forums to find a fix but to no avail.

As of right now, I simply want to make the stepper motor turn on and to see the LEDs blink, showing that it is receiving output signals from the Arduino's digital PWM pins. I have tried many codes from reputable sources, including the built-in stepper motor sketch that comes with the IDE. Our troubleshooting has been a mix of trying different wiring methods, using different power sources, and even using a completely new sets of hardware (Arduino, driver board, motor, and wires). I've come to the conclusion that we are obviously doing something wrong. However, I cannot spot what it is as we have followed each tutorial step by step.

I have attached a picture showing one wiring configuration that we used for a simple one revolution sketch.

Any help or guidance will be greatly appreciated!


Sketch Example 1:

/*
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 = 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, 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);
}


Sketch Example 2:


/*
Stepper Motor Control - one step at a time

This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.

The motor will step one step at a time, very slowly.  You can use this to
test that you've got the four wires of your stepper wired to the correct
pins. If wired correctly, all steps should be in the same direction.

Use this also to count the number of steps per revolution of your motor,
if you don't know it.  Then plug that number into the oneRevolution
example to see if you got it right.

Created 30 Nov. 2009
by Tom Igoe

*/

#include <Stepper.h>

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, 9, 10, 11);

int stepCount = 0;         // number of steps the motor has taken

void setup() {
 // initialize the serial port:
 Serial.begin(9600);
}

void loop() {
 // step one step:
 myStepper.step(1);
 Serial.print("steps:");
 Serial.println(stepCount);
 stepCount++;
 delay(500);
}


Sketch Example 3:

//original source is http://www.geeetech.com/wiki/index.php/Stepper_Motor_5V_4-Phase_5-Wire_%26_ULN2003_Driver_Board_for_Arduino
// Update by Ahmad Shamshiri for RoboJax.com
// Published on March 27, 2017 in Aajx, ON, Canada.

int Pin1 = 10;
int Pin2 = 11;
int Pin3 = 12;
int Pin4 = 13;
int _step = 0;
boolean dir = true;// false=clockwise, true=counter clockwise
int count=0;
void setup()
{
pinMode(Pin1, OUTPUT);  
pinMode(Pin2, OUTPUT);  
pinMode(Pin3, OUTPUT);  
pinMode(Pin4, OUTPUT);  
}
void loop()
{
switch(_step){
  case 0:
    digitalWrite(Pin1, LOW);  
    digitalWrite(Pin2, LOW);
    digitalWrite(Pin3, LOW);
    digitalWrite(Pin4, HIGH);
  break;  
  case 1:
    digitalWrite(Pin1, LOW);  
    digitalWrite(Pin2, LOW);
    digitalWrite(Pin3, HIGH);
    digitalWrite(Pin4, HIGH);
  break;  
  case 2:
    digitalWrite(Pin1, LOW);  
    digitalWrite(Pin2, LOW);
    digitalWrite(Pin3, HIGH);
    digitalWrite(Pin4, LOW);
  break;  
  case 3:
    digitalWrite(Pin1, LOW);  
    digitalWrite(Pin2, HIGH);
    digitalWrite(Pin3, HIGH);
    digitalWrite(Pin4, LOW);
  break;  
  case 4:
    digitalWrite(Pin1, LOW);  
    digitalWrite(Pin2, HIGH);
    digitalWrite(Pin3, LOW);
    digitalWrite(Pin4, LOW);
  break;  
  case 5:
    digitalWrite(Pin1, HIGH);  
    digitalWrite(Pin2, HIGH);
    digitalWrite(Pin3, LOW);
    digitalWrite(Pin4, LOW);
  break;  
    case 6:
    digitalWrite(Pin1, HIGH);  
    digitalWrite(Pin2, LOW);
    digitalWrite(Pin3, LOW);
    digitalWrite(Pin4, LOW);
  break;  
  case 7:
    digitalWrite(Pin1, HIGH);  
    digitalWrite(Pin2, LOW);
    digitalWrite(Pin3, LOW);
    digitalWrite(Pin4, HIGH);
  break;  
  default:
    digitalWrite(Pin1, LOW);  
    digitalWrite(Pin2, LOW);
    digitalWrite(Pin3, LOW);
    digitalWrite(Pin4, LOW);
  break;  
}
if(dir){
  _step++;
}else{
  _step--;
}
if(_step>7){
  _step=0;
}
if(_step<0){
  _step=7;
}
delay(1);

}

CrossRoads

Need to see some simple code that you say is not working.
I am using Stepper.h with 7 motors on a '1284P, it works fine.
Even ran 2 motors from simple 5V regulator, issue.

Possibly you don't have the pins ordered correctly in the code:

Stepper stepper0(STEPS, 5, 3, 4, 2); //create the stepper0  <<< Order here is important
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

AntSeniorProject

I've edited my post to show 3 examples of sketches we tried to used. The First two were built in examples from the IDE and the other was from a youtube tutorial from RoboJax: https://www.youtube.com/watch?v=KfAnUgaSDmI&feature=emb_logo.

We've been sure to follow the wiring schematics and the code provided from multiple sources. However, I do find it interesting that the built in IDE examples do not follow the same order as some other online sources, including your self has shown.

Go Up