# DC motor makes noise but does not rotate

i am following Jeremy blum's tutorial on youtube. link i have done the exact same circuit design as he has.

but the dc motor just makes a continuous beep sound when i run this code.

``````int motorPin = 9;

void setup()
{
pinMode(motorPin, OUTPUT);
}

void loop()

{
for(int i = 0; i <= 255; i++)
{
analogWrite(motorPin, i);
delay(10);
}

delay(500);

for(int i = 255; i >= 0; i--)
{
analogWrite(motorPin, i);
delay(10);
}

delay(500);
}
``````

I am clueless as to why this is happening. would be glad if someone could help me out here.

• What are the specs of your motor (current rating)? What is the transistor model you have used? – alexan_e Jul 26 '14 at 7:58
• Could be an AC motor. Try connecting it directly to a 9v battery or some other power source, and see if it turns – Gerben Jul 26 '14 at 10:32
• Or just change pin 9 to HIGH to see if your circuit is working right an inertia is stopping the motor from turning. – Anonymous Penguin Jul 26 '14 at 19:54

I'm wondering if a 10 ms delay between steps is long enough for the motor to respond, especially with a cap across its terminals. Besides that the whole thing is over in 5 seconds.

It seems to me that AnalogWrite generates a PWM signal of about 500hz or about 2ms wave period. So in 10 ms you get 5 pulses of the same amplitude and smoothed by the cap. At low values of "i", say i=10, then the pulse is only 10/255*2ms wide or about 78uS. At low values of i, a 180deg rotation has to occur in the time you apply the pulse for the motor to rotate, well not exactly but close enough.

Most small DC motors are 2 pole, so you're expecting at least one 180degree rotation in 5x78uS or about in 400uS. That would be a full rotation in about 800uS, say 1mS, or 1000 rotations in 1 second, or 60000rpm, from a standing start if the duty cycle was held constant. You have very little power at low "i" so I'd be surprised if there is enough to overcome friction and inertia. On higher values I guess it's still not enough to overcome the inertia.

The motor well may run at the higher values of "i" but then the program immediately counts down again.

So I suggest you start the counter at say 125 or even higher. Also make the delay between counting up and counting back down much longer so you can actually see the effect before it counts down again. I would also want to make the delay between counts higher so there is more time for current to flow in the motor's (inductive) windings. Remember an inductor resists a change in current. Now that I think about it, this is probably more important than the inertia and friction.

So here is a challenge... Change the delay between counts first, and report your results here. Then reset that and change a different parameter, and so on. Eventually make a number of changes together...I'm curious to see the outcome.

By the way, I suspect the sound is from the motor laminations changing shape at high frequency.

Cheers P

analogWrite uses PWM. Is the motor you are using designed for pulsed operation? Try using

``````digitalWrite(motorPin, HIGH);
``````
• The question should be not so much if the motor is designed for pulsed operation, but if the duty cycle, supply, and driver circuit are delivering sufficient power. Commanding 100% duty cycle in this manner is indeed one of the key tests which should be run (except in the atypical case where the driver is capable of delivering an unsafe amount of power) – Chris Stratton Jul 27 '14 at 15:19

I had the same issue, turns out that i had configured the BJT wrong. I had confused the drain for the collector.