Code and diagram help(i dont know why when i run the simulation the motors do not start miving)

#include <Stepper.h>

// Define the number of steps per revolution for your stepper motors
const int stepsPerRevolution = 200;

// Create instances of the Stepper class for each stepper motor
Stepper stepper1(stepsPerRevolution, 2, 3, 4, 5);  // Synchronized motor 1
Stepper stepper2(stepsPerRevolution, 6, 7, 8, 9);  // Synchronized motor 2
Stepper stepper3(stepsPerRevolution, 10, 11, 12, 13);  // Clamping system motor
Stepper stepper4(stepsPerRevolution, 14, 15, 16, 17);  // Separate motor 1
Stepper stepper5(stepsPerRevolution, 18, 19, 20, 21);  // Separate motor 2

// Define the number of steps to rotate the clamping system motor for a 45-degree rotation
const int clampingSystemSteps = stepsPerRevolution / 8;  // Assuming 8 steps for a 45-degree rotation

// Push button pins
const int buttonSyncPin1 = 22; // Push button for synchronized motors forward
const int buttonSyncPin2 = 23; // Push button for synchronized motors backward
const int button3Pin1 = 24; // Push button for clamping system forward
const int button3Pin2 = 25; // Push button for clamping system backward
const int button4Pin1 = 27; // Push button for separate motor 1 forward
const int button4Pin2 = 29; // Push button for separate motor 1 backward
const int button5Pin1 = 31; // Push button for separate motor 2 forward
const int button5Pin2 = 33; // Push button for separate motor 2 backward

void setup() {
  // Setup push button pins as inputs
  pinMode(buttonSyncPin1, INPUT_PULLUP);
  pinMode(buttonSyncPin2, INPUT_PULLUP);
  pinMode(button3Pin1, INPUT_PULLUP);
  pinMode(button3Pin2, INPUT_PULLUP);
  pinMode(button4Pin1, INPUT_PULLUP);
  pinMode(button4Pin2, INPUT_PULLUP);
  pinMode(button5Pin1, INPUT_PULLUP);
  pinMode(button5Pin2, INPUT_PULLUP);

  
  // Set the speed for each stepper motor (in RPM)
  stepper1.setSpeed(60); // Synchronized motor 1
  stepper2.setSpeed(60); // Synchronized motor 2
  stepper3.setSpeed(60); // Clamping system motor
  stepper4.setSpeed(60); // Separate motor 1
  stepper5.setSpeed(60); // Separate motor 2
}

void loop() {
  // Synchronized motors control
  if (digitalRead(buttonSyncPin1) == LOW) {
    stepper1.step(stepsPerRevolution); // Move motor 1 forward one revolution
    stepper2.step(stepsPerRevolution); // Move motor 2 forward one revolution
  } else if (digitalRead(buttonSyncPin2) == LOW) {
    stepper1.step(-stepsPerRevolution); // Move motor 1 backward one revolution
    stepper2.step(-stepsPerRevolution); // Move motor 2 backward one revolution
  }

  // Clamping system motor control
  if (digitalRead(button3Pin1) == LOW) {
    stepper3.step(clampingSystemSteps); // Move motor forward for a 45-degree rotation
  } else if (digitalRead(button3Pin2) == LOW) {
    stepper3.step(-clampingSystemSteps); // Move motor backward for a 45-degree rotation
  }

  // Separate motor 1 control
  if (digitalRead(button4Pin1) == LOW) {
    stepper4.step(stepsPerRevolution); // Move motor forward one revolution
  } else if (digitalRead(button4Pin2) == LOW) {
    stepper4.step(-stepsPerRevolution); // Move motor backward one revolution
  }

  // Separate motor 2 control
  if (digitalRead(button5Pin1) == LOW) {
    stepper5.step(stepsPerRevolution); // Move motor forward one revolution
  } else if (digitalRead(button5Pin2) == LOW) {
    stepper5.step(-stepsPerRevolution); // Move motor backward one revolution
  }
}
![Capture|690x481](upload://oXP9whHWX1gXfQauXZ8zwzraLvz.png)

i wanna control 5 stepper motor using push button .There are 2 motors that are synchronized like they should move at the same time and the others are independant and each motor will have 2 push button one to ensure the forward motion and the other the backward motion but the 2 motors that are synchronize will share the same push button in order to receive the same signal and move at the same time.

THANKS IN ADVANCE
JUST TO MENTION THAT IT IS MY FIRST TIME HERE

It looks like your Enable pins are just tied together but not tied to GND or VCC so the driver boards are probably not enabled and ready to move the motors.

And great job using code tags on your first post!

So should i connect them to the ground or one to the vcc and the other to the ground

It looks like if you tie ENA and ENB together, you just get maximum speed which is okay.

You can always put some debug Serial.print() statements in your code to verify that the buttons are being read properly and the motors should be moving.

You should also take a look at the State Change Detection example. It will show you how to determine when a button is pressed, not if a button is pressed.

the questions still apply

yes i did the design myself

The motor are not working

it feels like getting information from you is like pulling teeth.

I don't plan to keep asking for details and get 3 word answers

Good luck with your project.

1 Like

welcome to the arduino-forum.

put yourself in the position of another forum-member.

How much does a forum-member know about your project?
Your schematic and no code. Because you deleted the posting with the code.

How much help can somebody give on this base of information?

I'm pretty sure that you agree and will follow the way how to solve your problem mimimum 200 minutes faster.
This requires to invest 20 minutes of your precious time to read how to speedup solving your problems.

Directly after registering you got presented informations how to speed up solving your problem.
You should really read it.

best regards Stefan

don't know what the code is expected to do?
can't guess without seeing the code

don't know what type motors are being used (DC, stepper)?
the L298 driver is for DC motors and can drive 2 motors, but DC motors have just 2 connections.
shouldn't ENA and ENB be connected to a PWM signal?

don't know what the switches are intended to do? why 8?

I have merged your cross-posts @magui-1998.

Cross-posting is against the Arduino forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting can result in a suspension from the forum.

In the future, please only create one topic for each distinct subject matter. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

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