Is there anyone who can help me?

I changed the pins to 11,10,9,8 and it works now, the program generated the code, the only mistake was in the pin design.

But he didn't create it to run two motors at the same time, he created a code so that when one motor makes a turn, it stops and the other motor does the same.

#include <Stepper.h>

// Define steps per revolution (for 28BYJ-48, it's usually 2048 in full-step mode)
const int stepsPerRevolution = 2048;

// Initialize the stepper motors
Stepper stepper1(stepsPerRevolution, 8, 10, 9, 11); // IN1-IN4 for motor 1
Stepper stepper2(stepsPerRevolution, 4, 6, 5, 7); // IN1-IN4 for motor 2

void setup() {
// Set speed to 15 RPM
stepper1.setSpeed(15);
stepper2.setSpeed(15);
}

void loop() {
// Step one full revolution in forward direction
stepper1.step(stepsPerRevolution);
stepper2.step(stepsPerRevolution);
}

Please use code tags

Just spinning all motors at a constant speed is easy. no library needed.

I just wrote this sketch and tested it with three motors on an Uno R3.

Leo..

// 28BYJ-48_test

const byte pins[] {4, 5, 6, 7, 8 ,9 ,10 ,11 ,A0 ,A1 ,A2 ,A3}; // sets of four to each ULN IN 1-4
const byte coils[] {B0001, B0010, B0100, B1000}; // lower current or
// const byte coils[] {B1001, B0011, B0110, B1100}; // higher torque

void setup() {
  for (byte i = 0; i < sizeof(pins); i++) pinMode(pins[i], OUTPUT);
}

void loop() {
  for (byte i = 0; i < 4; i++) {
    digitalWrite(pins[i], bitRead(coils[(millis() >> 1 & 3)], i));
    digitalWrite(pins[i+4], bitRead(coils[(millis() >> 1 & 3)], i));
    digitalWrite(pins[i+8], bitRead(coils[(millis() >> 1 & 3)], i));
    //digitalWrite(pins[i+12], bitRead(coils[(millis() >> 1 & 3)], i));
    //digitalWrite(pins[i+16], bitRead(coils[(millis() >> 1 & 3)], i));
    }
}
3 Likes

Vely crever, I like. :grin:

I have no idea what tags are.

Thanks, I'll try it tonight, I'm out all day today

Hello, do yourself a favour and please read How to get the best out of this forum and post accordingly (including code with code tags and necessary documentation for your ask like your exact circuit and power supply, links to components etc).

Thanks again, the code works beautifully.

I admit I didn't read any rules. I thought I would write a request and someone would be interested in generating codes for me. I didn't know that I had to go to another section for this and it seemed unnecessary to me. This project is not my hobby or any extra hobby, it is something I came up with myself that I want to put on the market, so I don't want to publish any details here. I really thought that I would enter what I need and someone would generate the code, I don't know anything about Arduino at all but I know that what I need are the simplest codes.
Thank you very much again and respect to those who without unnecessary words put the code here and refused the money.
I will probably need more of these codes, so I ask again, is anyone willing to cooperate with me? Of course for money.

Last time I will say this.

see post #49

  • We need to see a schematic showing all the interconnections in this project.

  • Confirm the Arduino has a common GND connection to the driver power supply GND.

What's the difference? I wrote that I didn't want to publish any details, it seemed pointless to ask in the next room something that I could ask here too... in the other section I would write it the same way as here.

I don't have the Arduino connected to the driver via GND, is it important that it is connected?

I have it wired up as written in the code.

// 28BYJ-48_test

const byte pins[] {4, 5, 6, 7, 8 ,9 ,10 ,11 ,A0 ,A1 ,A2 ,A3}; // sets of four to each ULN IN 1-4
const byte coils[] {B0001, B0010, B0100, B1000}; // lower current or
// const byte coils[] {B1001, B0011, B0110, B1100}; // higher torque

void setup() {
  for (byte i = 0; i < sizeof(pins); i++) pinMode(pins[i], OUTPUT);
}

void loop() {
  for (byte i = 0; i < 4; i++) {
    digitalWrite(pins[i], bitRead(coils[(millis() >> 1 & 3)], i));
    digitalWrite(pins[i+4], bitRead(coils[(millis() >> 1 & 3)], i));
    digitalWrite(pins[i+8], bitRead(coils[(millis() >> 1 & 3)], i));
    //digitalWrite(pins[i+12], bitRead(coils[(millis() >> 1 & 3)], i));
    //digitalWrite(pins[i+16], bitRead(coils[(millis() >> 1 & 3)], i));
    }
}
  • There needs to be a common connection between the Arduino GND and the motor power supply GND.
    When the Arduino sends a signal from its output pins to the IN pins on the driver board, that signal has to get back the Arduino through a common GND (ground, 0v) connection.
1 Like

Thank you, this is important information.

Well I am here and here to stay. If you have a problem with me you can alert a moderator.

1 Like

Why are some people irritated that I don't disclose details and some are completely fine with it?