Arduino Motor Shield only works in one direction

Hello,

some here has experience with the arduino motor shield?

The motor is working only in one direction. I have a test-script, turning from one direction to other.
When running the arduino, the motor start turning forwards, then trying to turn backwards. But instead of turning backwards you hear a “click” and the motor spindle turn only a bit (maybe ~1 degree).

The motor is connected to + and - of the shield, and the external power supply to GND + VIN.

The board is an Arduino Duemilanove.

Thanks!

Yannick

void setup() {
  //Setup Channel A
  pinMode(12, OUTPUT); //Initiates Motor Channel A pin
  pinMode(9, OUTPUT); //Initiates Brake Channel A pin
}

void loop(){
  //forward
  digitalWrite(12, HIGH); //Establishes forward direction of Channel A
  digitalWrite(9, LOW);   //Disengage the Brake for Channel A
  analogWrite(3, 50);   //Spins the motor on Channel A at full speed
  
  delay(1000);
  digitalWrite(9, HIGH); //Eengage the Brake for Channel A
  delay(1000);
  
  //backward
  digitalWrite(12, LOW); //Establishes backward direction of Channel A
  digitalWrite(9, LOW);   //Disengage the Brake for Channel A
  analogWrite(3, 50);   //Spins the motor on Channel A at half speed
  
  delay(1000);
  
  digitalWrite(9, HIGH); //Eengage the Brake for Channel A 
  delay(1000);
}

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :slight_smile:

Hello everybody,

i found a solution for my problem :slight_smile:

The test code, i used from this website (https://www.instructables.com/id/Arduino-Motor-Shield-Tutorial/) was not correct.

After a long time, i noticed, that the pin allocation is not correct, and additionally stopping the motor doesn't work with the example script.

Pin 9 must be Pin 8, to stop the motor, the Pins 12 & 8 must set to LOW and to start the motor Pin 12 & 8 must set to opposite values for booth directions.

I wrote this code and share it with you, because this code now works for me:

void setup() {
  
  //Setup Channel A
 pinMode(12,OUTPUT);      //Initialize Channel A direction
 pinMode(8,OUTPUT);       //Initialize Channel A Break
  
}

void loop(){
  digitalWrite(12, LOW); //Forward direction Channel A
  digitalWrite(8, HIGH);   //Disengage the Brake for Channel A
  analogWrite(3, 255);   //Spins the motor on Channel A at full speed

delay(2000);
digitalWrite(8, LOW);
delay(2000);
  
  digitalWrite(12, HIGH); //Establishes direction Channel A
  digitalWrite(8, LOW);   //Disengage the Brake for Channel A
  analogWrite(3, 255);   //Spins the motor on Channel A at full speed

delay(2000);
digitalWrite(12, LOW);
digitalWrite(8, LOW);
delay(2000);
}

Best Regards,

Yannick