H bridge controller moves fast in one direction only

Hello

I have been trying to control a CD drive (Rack and Pinion door ) using my arduino and a H bridge controller and two PB one to open and one to close the door , it works but i am encountering some strange occurrences , The door would shut pretty quickly But when i send the signal to open the door it takes a long time and sticks allot , upon future investigation i realized that my output voltage for one the the output pins was giving 3 volts as high . i tried other pins and got the same result . wrote a small program to just send both pins high and i got 5V as High . I believe i have some issues in my program which is responsible for this behavior could some please advise me as to what i am doing wrong

This is the code for controlling the door

const int buttonPin = 13; // Moves door  Down
const int buttonPin2 = 10; // Moves door Up
const int A =  6;    //Output pin for AIA pin of H-bridge  
const int B =  7;    //Output pin for AIB pin of H-bridge 


int buttonState  = 0;        
int buttonState2 = 0; 


void setup() {
  
//Output pins
  pinMode(A, OUTPUT);
  pinMode(B, OUTPUT); 
  
//Input pins
  pinMode(buttonPin, INPUT);
  pinMode(buttonPin2, INPUT);  
}

void loop()
{
  
  buttonState2 = digitalRead(buttonPin2);
  
  if (buttonState2 == HIGH) 
    {         
     Up();
    }
  
  buttonState = digitalRead(buttonPin);
   
   if (buttonState == HIGH) 
    {       
      Down();
    } 
  
  else 
    {
      Stop();
    }
}


void Up ()
  {
    
    //Problem occures here Pin 6 "A" outputs 3V as high
    digitalWrite(A, HIGH);  
    digitalWrite(B, LOW);
  }

void Down()
  {
   digitalWrite(A, LOW); 
   digitalWrite(B, HIGH);
  }

void Stop()
  {
    digitalWrite(B, LOW);  
    digitalWrite(A, LOW); 
  }

And this is the code i used to test the output Voltage and i did confirm both pins had an output of 5V

const int A =  6;      
const int B =  7;



void setup() {

  pinMode(A, OUTPUT);
  pinMode(B, OUTPUT);  

 }

void loop()
{
    digitalWrite(A, HIGH);  
    digitalWrite(B, HIGH);
 
}

I am not sure where i have went wrong any help would gratefully appreciated

I'll bite.

I was looking at these H bridge drivers and don't like them for the simple fact they have no build in safeguard that both pins aren't high at the same time and "POW!" You kill the drivers.

They should be better designed.... But anyway.

How are you testing the voltage levels? With a meter? With or with out a load?

Get the H Bridge powered up and manually stimulate the inputs.
OF COURSE don't put them both high at the same time!

Set it to go one way then the other.
See what happens.

Is it the circuit "pulling" the arduino's output lower? (Or: Is it "shorting" the pin to ground?)

What I would do to cover my self is use a logic gate to prevent both pins ever being high at once.
An XOR gate on one of the inputs would/should suffice.

lost_and_confused:
I'll bite.

I was looking at these H bridge drivers and don't like them for the simple fact they have no build in safeguard that both pins aren't high at the same time and "POW!" You kill the drivers.

They should be better designed.... But anyway.

How are you testing the voltage levels? With a meter? With or with out a load?

Get the H Bridge powered up and manually stimulate the inputs.
OF COURSE don't put them both high at the same time!

Set it to go one way then the other.
See what happens.

Is it the circuit "pulling" the arduino's output lower? (Or: Is it "shorting" the pin to ground?)

What I would do to cover my self is use a logic gate to prevent both pins ever being high at once.
An XOR gate on one of the inputs would/should suffice.

I tested the output of each pin with a multimeter connected and disconnected from the Hbridge in both cases i found that Pin 6 was outputting 3V

i then ran the second code just to test the output voltage ,without the pin begin connected to anything and i found it was outputting 5V so i believe it has something to do with the code just dont know what yet , Can anyone identify the problem or have any ideas on what i should change

Your problem is in deed in your program.
Your logic says:
if you push button 1, make the motor go forward
if you don't push button 2, make the motor stop
Repeat.

Therefore, the motor will go forward and stop a few thousand times per second, thus giving the illusion of 3V (actuallly 0v, 5v, 0v, 5v extremely fast)

change your logic to use an else if:

  buttonState2 = digitalRead(buttonPin2);
  
  if (buttonState2 == HIGH) 
    {         
     Up();
    }
  
  buttonState = digitalRead(buttonPin);
   
   else if (buttonState == HIGH) //Here's the change, just add else to the start of this if 
    {       
      Down();
    } 
  
  else 
    {
      Stop();
    }

Now the code will say:
if button 1 is pushed, go forward and ignore everything else.

TRex:
Your problem is in deed in your program.
Your logic says:
if you push button 1, make the motor go forward
if you don't push button 2, make the motor stop
Repeat.

Therefore, the motor will go forward and stop a few thousand times per second, thus giving the illusion of 3V (actuallly 0v, 5v, 0v, 5v extremely fast)

change your logic to use an else if:

  buttonState2 = digitalRead(buttonPin2);

if (buttonState2 == HIGH)
   {        
    Up();
   }
 
 buttonState = digitalRead(buttonPin);
 
  else if (buttonState == HIGH) //Here's the change, just add else to the start of this if
   {      
     Down();
   }
 
 else
   {
     Stop();
   }



Now the code will say:
if button 1 is pushed, go forward and ignore everything else.

This worked thank your very much for your help