Ardiuno programming

Ive managed to build up my robot but i need help on programming.
my robot should be spinning clockwise and after 2 sec anti clockwise
but my Motor B is not working Please help me ? :frowning:

int dir1PinA = 2;
int dir2PinA = 3;
int speedPinA = 10;

int dir1PinB = 6;
int dir2PinB = 7;
int speedPinB = 11;

void setup () {
Serial.begin(9600);
pinMode(dir1PinA,OUTPUT);
pinMode(dir2PinA,OUTPUT);
pinMode(speedPinA,OUTPUT);
pinMode(dir1PinB,OUTPUT);
pinMode(dir2PinB,OUTPUT);
pinMode(speedPinB,OUTPUT);
}
void loop() {
digitalWrite(2,LOW);
digitalWrite(3,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,LOW);
analogWrite(10,250);
delay(2000);
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
digitalWrite(6,LOW);
digitalWrite(7,HIGH);
analogWrite(10,250);
delay(2000);
}

Welcome to the forum.
Please read the 2 posts at the top of the page and follow the advice about posting a programming question, particularly the use of code tags to make code easier to deal with in the forum.

Your code is more difficult to read than it needs to be. Why did you give pins names that are never used later in the program ? This means that to read your program it is necessary to keep referring to the pin names rather than being able to determine the purpose of a command directly.

 digitalWrite(dir1PinA, LOW);
 digitalWrite(dir2PinA, HIGH);
 digitalWrite(dir1PinB, HIGH);
 digitalWrite(dir2PinB, LOW);

is much easier to understand than

  digitalWrite(2,LOW);
  digitalWrite(3,HIGH);
 digitalWrite(6,HIGH);
 digitalWrite(7,LOW);

As to your problem. Which motor works if you change the connections between them ? Is the problem the motor or maybe the wiring rather than the program ?

Are you sure the red wire is in the correct place? :wink:

More information is needed.

You use variable to name your pins which is a good idea but then you use the pin number in the code. Why not use the variable names?

Please read the "How to use this forum" sticky and learn to use code tags.

I don't know why you're surprised motor B is "not working" when you never send it a speed setting.

You need a line like the one below.

    analogWrite(speedPinB, 250);

In the code you posted, you only use analogWrite with motor A.

Thank you Mr.DuaneDegn your code really helpd me.
:wink: :smiley_cat:
now my robot is movin fine.

Khatanbold:
Thank you Mr.DuaneDegn your code really helpd me.
:wink: :smiley_cat:
now my robot is movin fine.

Good to hear. Thanks for letting us know it's working.