Basic Code to controlling a DC Motor with a H-Bridge

Ive been playing around for a while, trying to control an DC Motor with an H-Bridge, but it doesnt seem to work at all. What am I doing wrong? A Picture of the circuit is attached and i wrote this:

int motor_A=6;
int motor_B=3;
int motor_Speed=5;

void setup()
{
pinMode(motor_A,OUTPUT);
pinMode(motor_B,OUTPUT);

//edit
pinMode(motor_Speed,OUTPUT); //why is this not done in tutorials? Anyway, sadly it doesn't work with or without

}

void loop(){
digitalWrite(motor_A,HIGH);
digitalWrite(motor_B,LOW);

analogWrite(motor_Speed,255);
delay(1000);

analogWrite(motor_Speed,0);
delay(1000);
}

Circuit_nv[1].jpg

Lichtbruno:
Ive been playing around for a while, trying to control an DC Motor with an H-Bridge, but it doesnt seem to work at all. What am I doing wrong? A Picture of the circuit is attached and i wrote this:

int motor_A=6;
int motor_B=3;
int motor_Speed=5;

void setup(){

pinMode(motor_A,OUTPUT);
pinMode(motor_B,OUTPUT);
}

void loop(){
digitalWrite(motor_A,HIGH);
digitalWrite(motor_B,LOW);

analogWrite(motor_Speed,255);
delay(1000);

analogWrite(motor_Speed,0);
delay(1000);
}

I do think that the error occur because you don't declare the pinMode for motor_Speed pin. Try to include pinMode(motor_Speed, OUTPUT).

Thanks.

Vincent19:
I do think that the error occur because you don't declare the pinMode for motor_Speed pin. Try to include pinMode(motor_Speed, OUTPUT).

Yes I was wondering why, in the tutorials i could find, they don't declare the enable Pin as an output...
I tried it already and it didn't work :(. Still no movement. Thanks though :).

just figured out the problem. The H Bridge doesnt fit well, I have to press it down on the Breadboard to get the motor running. Fail.

Vincent19:
I do think that the error occur because you don't declare the pinMode for motor_Speed pin. Try to include pinMode(motor_Speed, OUTPUT).

Thanks.

From this link to the reference page:

"You do not need to call pinMode() to set the pin as an output before calling analogWrite(). "