Arduino Motors Shield Issues

I am trying to do a project with the Arduino Motor shield. I need to spin Motor A forward, stop it, spin Motor B forward, stop it, spin Motor A backward, stop it, spin Motor B backward, and then stop it. My code only spins Motor A forward then Motor B forward. I have been trying to figure this out for a couple weeks now. I am using an Arduino Uno rev3 and the official Arduino Motor Shield. Here is my code:

void setup() {
  //Setup Channel A
  pinMode(12, OUTPUT); 
  pinMode(9, OUTPUT); 

  //Setup Channel B
  pinMode(13, OUTPUT); 
  pinMode(8, OUTPUT); 

  Serial.begin(9600);
  
}

void loop(){
                                       
   //Motor A forward @ full speed
  digitalWrite(12, HIGH); 
  digitalWrite(9, LOW); 
  analogWrite(3, 255);   
  delay(3000);
  digitalWrite(9, HIGH);

  

  digitalWrite(13, LOW);  
  digitalWrite(8, LOW);   
  analogWrite(11, 123);   
  delay(3000);
  digitalWrite(9, HIGH);
  

    
  digitalWrite(12, HIGH); 
  digitalWrite(9, LOW); 
  analogWrite(3, 255);   
  delay(3000);
  digitalWrite(9, HIGH);
  

  digitalWrite(13, LOW);  
  digitalWrite(8, LOW);  
  analogWrite(11, 123);    
  delay(3000);
  digitalWrite(9, HIGH); 
}

Thanks in Advance. Website

Hi,
Can you post link to spec/data of your motor shield, there are many different models/types.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Start by giving the pins some sensible names instead of anonymous numbers then write functions with sensible names to move the motors in the directions that you want and to stop them. Test each function on its own then combine them together in loop()

@minahil0 please provide an explanation for why you have asked the exact question here as was asked previously on Stack Overflow:
https://stackoverflow.com/questions/69329939/arduino-motors-shield-issues

Shouldn't that be HIGH/LOW or LOW/HIGH?

@minahil0 tick tock. The clock is swiftly approaching ban thirty and you still haven't answered my question.

Hi,
Hasn't been 24hours yet, don't know what part of the world he/she comes from.

Tom.. :smiley: :+1: :coffee: :australia:

Note that the asker of the original question was active responding on Stack Overflow 3 hours ago.

There is a common spam technique where a relevant question is scraped from one site (e.g., Stack Exchange, Reddit), then posted to another.

I know what I'm doing and have additional information that is only visible to moderators. So feel free to let me do my job.

1 Like

An H-bridge is high-low in one direction and low-high in the other. high-high and low-low both mean stop. beyond that I recommend moving to Arduino as this is about an arduino specific piece of hardware- the motor shield