how to switch a data line on and off with a digital output "smallest possible"

Hi i need to switch on and off some joining lines to a pair of stepper motors which is more pwm than data line but anyhow i have two and i need them to work at the same time and then separately.

I have my code working but he only issue is that i need to find a small component like a transistor to switch on and off the link lines to the steppers "4 lines so i would just get 4 transistors in parallel or whatever".

So my question is what is the best component for me to use to switch on and off these cables that link the steppers together with a digital output, any could anyone please be kind enough to show me a diagram ?

You should show us a diagram of what you are trying to do.

Show us a good schematic of your circuit.
Show us a good image of your wiring.

What kind of current, voltage, digital/analog?

How about relays?

i need to switch on and off some joining lines to a pair of stepper motors which is more pwm than data line

Please explain what you mean by "switch on and off".

What are "joining lines"?

What is "more pwm than data"?

Post a wiring diagram of your present setup (hand drawn, not a Fritzing pile), links to the stepper motors and motor drivers, and the code, using code tags.

See "How to use this forum" if you have questions about how to use this forum.

"switch on and off" - connect and disconnect. Link line, lines or cables as you prefer that link two or more components....

Ok i have two stepper motors each have four lines connected to the Arduino, due to the way the code works they can only rotate separately unless the corresponding lines to each stepper motor are linked together thus they act as one and turn at the same rate, so i currently have the first stepper motor running of pins 4,5,6,7 and stepper motor two 8,9,10,11 so they can work separately to turn and such then i need them linked so they work in perfect sync.

To link the stepper motors I also have a set of jumpers from the first stepper motor cables to the second stepper motor cables and a 4 way dip switch so when i flick the switch, if i run either stepper motor they both run. But i want to be able to use a digital output to a electrical component to switch off each of these four four cables that link each stepper cable to each other, instead of the dip switch, i don't want to use a relay they are to big and to power hungry, i was hoping for some kind of circuit using transistors which have in my draw "NPN transistors" but i can go to the store if in need something else, the steppers are 12v

Post a wiring diagram of your present setup (hand drawn, not a Fritzing pile), links to the stepper motors and motor drivers, and the code, using code tags.

See "How to use this forum" if you have questions about how to use this forum.

It sounds like what you need are a couple of stepper drivers with an enable. Feed the same four lines to the inputs of the drivers, and connect one stepper to one driver, and the other stepper to the other driver. Then feed the enable pins to a couple more Arduino outputs -- then use those outputs to enable or disable the drivers. Probably better to use a driver IC, rather than trying to do this with transistors.

Google: "stepper motor IC" or "Stepper driver IC"

And, I'm thinking if you can drive those steppers with an Arduino output, then probably any driver will do the job. Just make sure it has an enable or chip-select or the like. you might be able to find a dual driver that will do the whole job. Also, look at "break out" boards and stepper driver modules.

due to the way the code works they can only rotate separately unless the corresponding lines to each stepper motor are linked together

Then change the way the code works so you switch all the lines together. Their is no need to add any hardware to do this.

Grumpy_Mike:
Then change the way the code works so you switch all the lines together. Their is no need to add any hardware to do this.

Well, only if slight delays are tolerable, or if KawasakiZx10r dares to delve into the complexities discussed here: https://forum.arduino.cc/index.php?topic=40528.0

Well, only if slight delays are tolerable

Come off it! We are talking about a mechanical motor here you will not notice any delay.

Ok so i tried using a for loop to turn each stepper one step at a time for the length of the amount of steps in my case 200 steps at 1.8 degrees per turn but it was horrible the drone vibrates along the floor, so instead of making that circuit to join the two together i just went through the Stepper library code and made my own based on the library that does two motors at the same time or just one. it nothing special and because i am using the 200 stepper motors only i did not include the part the swaps between motor types though that would be simple. FYI i am using two TB6612 drivers boards and two stepper motor - NEMA-17 size - 200 steps/rev, 12V 350mA. All is working perfectly if you want to use the code below

int step_number = 0;
int direction = 0;
unsigned long last_step_time = 0;
unsigned long step_delay;
unsigned long steps = 200;
const byte stepperOnePin_1 = 4;
const byte stepperOnePin_2 = 5;
const byte stepperOnePin_3 = 6;
const byte stepperOnePin_4 = 7;
const byte stepperTwoPin_1 = 8;
const byte stepperTwoPin_2 = 9;
const byte stepperTwoPin_3 = 10;
const byte stepperTwoPin_4 = 11;
int speed = 30;
unsigned long currentMillis;

void setup() {
  Serial.begin(115200);
  step_delay = ((60000UL / steps) / speed);
  Serial.print("step_delay ");
  Serial.println(step_delay);
}

void loop() {
  stepTwo(200, true, true, false); // steps, select motor 1, select motor 2, invert directions "turn opposite direction to each other" 
  delay(3000); // not needed, just added to slow down loop !
  stepTwo(-200, true, true, false); // now test the steppers in reverse 
  delay(3000); // not needed, just added to slow down loop !
}

void stepTwo(int step, bool selectMotorOne, bool selectMotorTwo, bool invert) {
  int steps_left = abs(step);
  if (step > 0) {
    direction = 1;
    Serial.print("steps_left ");
    Serial.println(steps_left);
  }
  else if (step < 0) {
    direction = 0;
    Serial.print("steps_right ");
    Serial.println(steps_left);
  }
  while (steps_left > 0) {
    currentMillis = millis();
    if (currentMillis - last_step_time >= step_delay) {
      //Serial.println("timer met");
      last_step_time = currentMillis;
      if (direction == 1)
      {
        step_number++;
        if (step_number == steps) {
          step_number = 0;
        }
      }
      else
      {
        if (step_number == 0) {
          step_number = steps;
        }
        step_number--;
      }
      // decrement the steps left:
      steps_left--;
      int thisStep = step_number % 4;
      //Serial.println(step_number % 4);
      if (!invert) {
        switch (thisStep) {
          case 0:  // 1010
            if (selectMotorOne) { // motor 1
              digitalWrite(stepperOnePin_1, HIGH);
              digitalWrite(stepperOnePin_2, LOW);
              digitalWrite(stepperOnePin_3, HIGH);
              digitalWrite(stepperOnePin_4, LOW);
            }
            if (selectMotorTwo) {// motor 2
              digitalWrite(stepperTwoPin_1, HIGH);
              digitalWrite(stepperTwoPin_2, LOW);
              digitalWrite(stepperTwoPin_3, HIGH);
              digitalWrite(stepperTwoPin_4, LOW);
            }
            break;
          case 1:  // 0110
            if (selectMotorOne) { // motor 1
              digitalWrite(stepperOnePin_1, LOW);
              digitalWrite(stepperOnePin_2, HIGH);
              digitalWrite(stepperOnePin_3, HIGH);
              digitalWrite(stepperOnePin_4, LOW);
            }
            if (selectMotorTwo) {
              digitalWrite(stepperTwoPin_1, LOW);
              digitalWrite(stepperTwoPin_2, HIGH);
              digitalWrite(stepperTwoPin_3, HIGH);
              digitalWrite(stepperTwoPin_4, LOW);
            }
            break;
          case 2:  // 0101
            if (selectMotorOne) { // motor 1
              digitalWrite(stepperOnePin_1, LOW);
              digitalWrite(stepperOnePin_2, HIGH);
              digitalWrite(stepperOnePin_3, LOW);
              digitalWrite(stepperOnePin_4, HIGH);
            }
            if (selectMotorTwo) {
              digitalWrite(stepperTwoPin_1, LOW);
              digitalWrite(stepperTwoPin_2, HIGH);
              digitalWrite(stepperTwoPin_3, LOW);
              digitalWrite(stepperTwoPin_4, HIGH);
            }
            break;
          case 3:  // 1001
            if (selectMotorOne) { // motor 1
              digitalWrite(stepperOnePin_1, HIGH);
              digitalWrite(stepperOnePin_2, LOW);
              digitalWrite(stepperOnePin_3, LOW);
              digitalWrite(stepperOnePin_4, HIGH);
            }
            if (selectMotorTwo) {
              digitalWrite(stepperTwoPin_1, HIGH);
              digitalWrite(stepperTwoPin_2, LOW);
              digitalWrite(stepperTwoPin_3, LOW);
              digitalWrite(stepperTwoPin_4, HIGH);
            }
            break;
        }
      }
      else {
        Serial.println("inverted");
        switch (thisStep) {
          case 0: // 1001
            if (selectMotorOne) { // motor 1
              digitalWrite(stepperOnePin_1, HIGH);
              digitalWrite(stepperOnePin_2, LOW);
              digitalWrite(stepperOnePin_3, HIGH);
              digitalWrite(stepperOnePin_4, LOW);
            }
            if (selectMotorTwo) {
              digitalWrite(stepperTwoPin_1, HIGH);
              digitalWrite(stepperTwoPin_2, LOW);
              digitalWrite(stepperTwoPin_3, LOW);
              digitalWrite(stepperTwoPin_4, HIGH);
            }
            break;
          case 1:  // 0101
            if (selectMotorOne) { // motor 1
              digitalWrite(stepperOnePin_1, LOW);
              digitalWrite(stepperOnePin_2, HIGH);
              digitalWrite(stepperOnePin_3, HIGH);
              digitalWrite(stepperOnePin_4, LOW);
            }
            if (selectMotorTwo) {
              digitalWrite(stepperTwoPin_1, LOW);
              digitalWrite(stepperTwoPin_2, HIGH);
              digitalWrite(stepperTwoPin_3, LOW);
              digitalWrite(stepperTwoPin_4, HIGH);
            }
            break;
          case 2:  //0101
            if (selectMotorOne) { // motor 1
              digitalWrite(stepperOnePin_1, LOW);
              digitalWrite(stepperOnePin_2, HIGH);
              digitalWrite(stepperOnePin_3, LOW);
              digitalWrite(stepperOnePin_4, HIGH);
            }
            if (selectMotorTwo) {
              digitalWrite(stepperTwoPin_1, LOW);
              digitalWrite(stepperTwoPin_2, HIGH);
              digitalWrite(stepperTwoPin_3, HIGH);
              digitalWrite(stepperTwoPin_4, LOW);
            }
            break;
          case 3:  // 1001
            if (selectMotorOne) { // motor 1
              digitalWrite(stepperOnePin_1, HIGH);
              digitalWrite(stepperOnePin_2, LOW);
              digitalWrite(stepperOnePin_3, LOW);
              digitalWrite(stepperOnePin_4, HIGH);
            }
            if (selectMotorTwo) {// motor 2
              digitalWrite(stepperTwoPin_1, HIGH);
              digitalWrite(stepperTwoPin_2, LOW);
              digitalWrite(stepperTwoPin_3, HIGH);
              digitalWrite(stepperTwoPin_4, LOW);
            }
            break;
        }
      }
    }
  }
}