Motor on fast, off slow

Hi all,

I’ve been hooked, lined, and sinkered into Arduino over the last week or so and am excited to start participating on these forums. Tonight’s experiment resulted in something that didn’t make sense, so I thought I’d reach out to see what others though.

I wanted to see my new XBees in action as well as play around with a motor. I first played with the “Motorized Pinwheel” example from the Arduino Projects Book - all was well there. I then programmed my XBees and was able to see them communicate correctly from X-CTU in one window and the serial monitor in another. The next logical step, I thought, was to modify the sketch so the motor turned on with one key’s press and turned off with another’s.

I have one Xbee plugged into my laptop’s USB port and I’m using X-CTU’s terminal tab to send data through it. The other Xbee is attached to my Xbee Shield on top of an Uno. I modified my sketch (below) and was able to turn the motor on when I pressed the “Q” key and turn it off when I pressed the “P” key.

When I press “Q” to turn it on, the motor instantly jumps on to fullspeed. When I press the “P” key to turn it off, it takes ~25 seconds to turn off - it slowly winds down to a halt. This is what I didn’t expect and don’t currently understand why.

Can you shine some light on the situation?

const int motorPin = 9;

void setup(){

void loop(){
  while(Serial.available() == 0);
  int data =;
  Serial.print("Data:  ");
  if (data == 113){
    digitalWrite(motorPin, HIGH);
  else if (data == 112){
    digitalWrite(motorPin, LOW);

Image attached.

Sort of a WAG, but...
Connect (add) a resistor, anything from 3K to 10K, from motorPin to Gnd.

If you turn the motor off by shorting its terminals it will stop really fast(*). Just disconnecting the
supply lets the motor coast - you need current flowing to generate torque.

(*) For a large motor this will be destructively fast in practice.

Just disconnecting the supply lets the motor coast ...

it takes ~25 seconds to turn off - it slowly winds down to a halt.

It's just a mabuchi motor and I think what's probably a FET there has no discharge path on its Gate and so my gentle recommedation.

Just a quick thanks for the responses!

So how did things go?