# 2 Direction Motor [closed]

Using an Arduino-Nano, I'm trying to make a circuit that will change the direction of a motor based on two inputs. The input from the Arduino will be amplified by a transistor. Here's the code:

``````int rightIn = 2;
int rightOut = 3;
int leftIn = 4;
int leftOut = 5;
int rightVal = 0;
int leftVal = 0;

void setup() {
pinMode(rightIn, INPUT);
pinMode(leftIn, INPUT);
pinMode(rightOut, OUTPUT);
pinMode(leftOut, OUTPUT);
Serial.begin(9600);
}

void loop() {
Serial.println(rightVal);
if ((rightVal == HIGH) || (leftVal == HIGH)) {
if (rightVal == HIGH) {
digitalWrite(rightOut, HIGH);
digitalWrite(leftOut, LOW);
}
if (leftVal == HIGH) {
digitalWrite(rightOut, LOW);
digitalWrite(leftOut, HIGH);
}
}
else {
digitalWrite(rightOut, LOW);
digitalWrite(leftOut, LOW);
}
}
``````

And the arduino wiring:

• Pins 3 and 5 are attached to the motors power and ground
• Pins 2 ad 4 go to an seprate inputs

## closed as unclear what you're asking by Chris Stratton, Mattia, Dave X, Paul, RSMJun 1 '16 at 7:26

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• And your question is? The Stack Exchange sites require stating a clear, answerable problem – Chris Stratton May 14 '16 at 1:11
• Please read How do I ask a good question? - you have stated what you want. Now you need to describe what is happening, compared to what you want to have happen. – Nick Gammon May 20 '16 at 5:59

I think you are mixing up your `rightVal` and `rightIn`, and your `leftVal` and `leftIn`.
``````rightVal = digitalRead(rightIn);