DC motor not spinning when powered by 12V supply - Arduino Uno with Motor Shield REV3

Code:

int directionPin = 12;
int pwmPin = 3;
int brakePin = 9;

//uncomment if using channel B, and remove above definitions
//int directionPin = 13;
//int pwmPin = 11;
//int brakePin = 8;

void setup() {
Serial.begin(9600);
Serial.println("setup");

//define pins
pinMode(directionPin, OUTPUT);
pinMode(pwmPin, OUTPUT);
pinMode(brakePin, OUTPUT);

}

void loop() {
Serial.println("program start");
digitalWrite(directionPin, HIGH);
Serial.println("reached forward direction");

//release breaks
digitalWrite(brakePin, LOW);
Serial.println("disengage brake");
 
//set work duty for the motor
analogWrite(pwmPin, 5);
Serial.println("spin motor");

delay(10000);
}

All the serial println commands are going through but the motor seems to not be rotating. It somehow worked the first ever time I ran the program but it hasn't ever since.

Using this setup:

Where is the UNO? Show the lot.

works after trying

analogWrite(pwmPin, 254);

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.