StepperMotor with 2 connection pins from Driver

Can a stepper motor with 2 connection pins from a driver still move in both the counter clockwise and clockwise directions? Using the following code and need motors to rotate both back and forth. I tried doing this with (+) and (-) steps but can’t seem to get the (-) steps to work.

//Starting with 3 sensors and 3 motors.
// each motor is connected to a gate within a maze. Gates 1 and 2 are open at the start of the experiment. Gate three is closed.
//A proximity sensor is placed after each gate. Sensor 1, when triggered, while cause two things:
//motor 1 to rotate 90 degrees counterclockwise (to close gate 1),
// and motor 3 to rotate 90 degrees clockwise (to open gate 3).
//The remaining two sensors will open and close the other two gates in a similar fashion.

#include <Stepper.h>
const int stepsPerRevolution = 128;

//declaring pins for motors 1, 2, and 3 (motors will be configured to rotate clockwise 90 degrees (open position) or rotate counter clockwise 90 degrees (closed position))
Stepper motor1(stepsPerRevolution, 1, 2);
Stepper motor2(stepsPerRevolution, 3, 4);
Stepper motor3(stepsPerRevolution, 5, 6);

// declaring pins for proximity sensors 1, 2, and 3
int sensor1 = 8;
int sensor2 = 9;
int sensor3 = 10;

//seting up variables to read sensor values (low when triggered, high when not triggered)
int sensor1value;
int sensor2value;
int sensor3value;

//defining motor states
int counter1 = 0; //open
int counter2 = 0; //open
int counter3 = 1; //closed

void setup() {
  pinMode(sensor1, INPUT);
  pinMode(sensor2, INPUT);
  pinMode(sensor3, INPUT);

  motor1.setSpeed(60);
  motor2.setSpeed(60);
  motor3.setSpeed(60);
}

void loop()
{
  //read sensor values
  sensor1value = digitalRead(sensor1);
  sensor2value = digitalRead(sensor2);
  sensor3value = digitalRead(sensor3);

  if (sensor1value == LOW) //if sensor 1 is triggered
  {
    if (counter1 == 0) //and if gate 1 is open
    {
      motor1.step(-500); //rotate motor 1 counterclockwise 90 degrees (close gate 1)
      counter1 = 1; //note that gate 1 is now closed
      motor3.step(-544); //rotate motor 3 clockwise 90 degrees (open gate 3)
      counter3 = 0; //note that gate 3 is now open
    }
  }

  if (sensor2value == LOW)
  {
    if (counter2 == 0)
    {
      motor2.step(-500);
      counter2 = 1;
      motor1.step(500);
      counter1 = 0;
    }
  }

  if (sensor3value == LOW)
  {
    if (counter3 == 0);
    {
      motor3.step(500);
      counter3 = 1;
      motor2.step(500);
      counter2 = 0;
    }
  }
}

Hi, What motor is this? Pointer to info?

pek9: Can a stepper motor with 2 connection pins from a driver

Do you mean 2 connections between the motor and the driver (unlikely, there are usually 4) or 2 connections between the driver and the Arduino - which is quite common.

But you need to post a link to the datasheet for the motor and for your stepper driver.

...R Stepper Motor Basics Simple Stepper Code

^that containts pretty much all of the infromation on the stepper motor and driver.

I am using a 28byj-48 stepper motor with the unl2003 drive with the Stepper. library on Arudino uno.

pek9: I am using a 28byj-48 stepper motor with the unl2003 drive with the Stepper. library on Arudino uno.

Then the question in your Original Post does not make sense "Can a stepper motor with 2 connection pins from a driver still move in both the counter clockwise and clockwise directions?" because a ULN2003 needs more than 2 connections.

...R