The Problem I Have With Digital Pins And The Motor

Last Month, I purchased an Arduino Micro from arduino.cc. For the most part, it has been fine, but I am at a part in my project where I need at attach a DC motor to a digital pin. The motor will spin when it is connected to the +5V pin, but when I attach it to a digital pin that is turned on, it will not spin, even though when I disconnect it and get a reading with my multimeter, it ways 5V. Here is the simple code I tried to use:

int motorPin = 3;

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

void loop() {
   digitalWrite(motorPin, HIGH);
}

I then tried attaching a 2N2222A transistor and 1N4007 diode and using a different (same model, different motor) motor, but the same problem occurred. Here is a link to the motor I used:

Amazon.com.

I tested the circuit with a LED in place of the motor and it turned on.

My Question is, is this a problem with the Arduino, the motor, or something I can solve on my own?

Trying to drive a motor directly off an output pin is a great way to fry an Arduino pin. The pins can't handle anything close to that type of current, not even for small motors, especially starting them up.

If it didn't work with the transistor then maybe you did it wrong. I can't see what you tried so I can't tell you. I can definitely tell you that driving a motor with a transistor works. So if it didn't work for you then it is definitely something you did wrong.

pinMode(motorPin, HIGH);
Use:
pinMode(motorPin, OUTPUT);

You cannot power a motor from a controller pin directly.


Examples of motor drive circuits:


The 5v pin on an Arduino can only supply small amount of current to a load, never a motor !