Go Down

Topic: Arduino Motor Sheild & DC Motor (Read 520 times) previous topic - next topic


I can not find anything on the WEB about using the Arduino Motor Sheild to control a DC Motor.  My understanding is that it can control 2 DC Motors.  I asume the motor would be connected to either the A or B two screw downs on the blue block.  If not correct then how?

After I plug the Arduino Motor Sheild into the Arduino, how do I program the Arduino then.



"Could you do the egg bacon spam and sausage without the spam then? "

No PMs for help please.
DO NOT power servos from Arduino 5V: give them their own power and connect the grounds.


Yes it did help.  Thanks.  Based on it I was able to get variable speed from the motors.  Simplified code follows:

#define DIRA            12                  // Direction motor pin
#define DIRB            13                  // Direction motor pin
#define PWMA            3                   // PWM motor pin
#define PWMB            11                  // PWM motor pin
#define BREAKA          9                   // Break A
#define BREAKA          1                   // Break B
#define CURRENTA        A0                  // Current Sensing A
#define CURRENTB        A1                  // Current Sensing B

int PWM_val = 0;                                // (25% = 64; 50% = 127; 75% = 191; 100% = 255)

void setup()
  analogReference(EXTERNAL);                            // Current external ref is 3.3V
//  Serial.begin(115600);
  pinMode(DIRA, OUTPUT);
  pinMode(DIRB, OUTPUT);
  pinMode(PWMA, OUTPUT);
  pinMode(PWMB, OUTPUT);
  digitalWrite(CURRENTA, HIGH);                     
  digitalWrite(CURRENTB, HIGH);

  analogWrite(PWMA, PWM_val);
  analogWrite(PWMB, PWM_val);
  digitalWrite(DIRA, HIGH);
  digitalWrite(DIRB, HIGH);
} /* setup */

void loop() {

  for (PWM_val = 0; PWM_val <= 255; PWM_val = PWM_val +10)
    analogWrite(PWMA, PWM_val);                                               // send PWM to motor
    analogWrite(PWMB, PWM_val); 
    Serial.print("PWM:");          Serial.print(PWM_val);  Serial.print("\n");
  } /* for */

} /* loop */

Go Up