Motor Shield

Hello,
I am having some trouble with trying to get my motor to run off two push button switches. I want it to run in one direction when one is pushed and in the other direction when the other one is pushed. I am using an Arduino Uno along with the MD10A motor shield (10Amp 7V-30V DC Motor Driver Shield for Arduino).

The problem I am encountering is that the motor will run fine in one direction, but when I push the other button the motor runs extremely slowly (Less than 1rpm). I have switch the push buttons both manually and by changing the pin call outs. Below is the code I am using, the motor is a 9v electric motor.

//This is the test code:
const int switchPin = 5;
const int pinPwm = 3;
const int pinDir = 2;
const int limitCounter = 4;

int switchState = 0;
int counterState = 0;
void setup() {
pinMode(pinPwm,OUTPUT);
pinMode(switchPin,INPUT);
pinMode(pinDir,OUTPUT);
pinMode(limitCounter,INPUT);
Serial.begin(9600);
}
void loop() {
switchState = digitalRead(switchPin);
if (switchState == 1) {
digitalWrite(pinDir,LOW);
analogWrite(pinPwm, 50);
Serial.println("fwd");
}
else {
digitalWrite(pinDir,HIGH);
analogWrite(pinPwm, 0);
}

counterState = digitalRead(limitCounter);
if (counterState == 1) {
digitalWrite(pinDir,LOW);
analogWrite(pinPwm, 50);
Serial.println("rev");
}
else {
digitalWrite(pinDir,LOW);
analogWrite(pinPwm, 0);
}
delay(10);
}

Well you are setting the PWM differently according to the button state, so that figures.

I just saw that and changed it, and am still having the problem of the motor running very slowly when the second push button is hit.

It is moving in pulses and the indicator light is very dim.

How ever both the forward and reverse test buttons on the shield work fine. I also have 10K resistors in parallel with the switches so that the arduino can read an actual low signal.

I'm out of ideas, any help would be greatly appreciated.

I wasn't out of ideas. I figured it out I needed to use an "if else" statement that way it wasn't trying to both stop the motor and start it in reverse at the same time. Below is the new code incase someone else runs into the same problem.

//This is a simple test code:
const int switchPin = 5;
const int pinPwm = 3;
const int pinDir = 2;
const int limitCounter = 4;

int switchState = 0;
int counterState = 0;
void setup()
{
pinMode(pinPwm,OUTPUT);
pinMode(switchPin,INPUT);
pinMode(pinDir,OUTPUT);
pinMode(limitCounter,INPUT);
Serial.begin(9600);
}
void loop()
{
switchState = digitalRead(switchPin);
counterState = digitalRead(limitCounter);
if (switchState == 1)
{
digitalWrite(pinDir,LOW);
analogWrite(pinPwm, 50);
Serial.println("fwd");
}

else if (counterState == 1)
{
digitalWrite(pinDir,HIGH);
analogWrite(pinPwm, 50);
Serial.println("rev");
}
else
{
analogWrite(pinPwm, 0);
}
delay(10);
}