Controlling dc motor with power supply instead of arduino.

Hi Everyone,

I followed the example for dc motors basic connection and was able to get my motor working. Then i moved the power to a power supply for the motor while still using usb to power arduino... uSING The basic sketch.. the motor turns on but will not turn off with any number i input... I drew up the connections.. what am i doing wrong here?

6V Motor
270 ohm resistor
pn2222 transistor
n4001 diode

Fritzing diagrams are usually worthless as well as misleading, but yours shows only one wire to the motor. There are probably two wires, and both need to be connected properly.

Next time, please post a hand drawn sketch of the wiring or a very clear photo. We can't see your code, either.

Is your motor connected to ground?

wire is connected to ground my bad but it still doesn't want to stop or slow down.

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Tom.... :slight_smile:
Even a picture of your project as well will help us.

2N2222 cannot handle more than 0.6A or so driven from an Arduino pin, and its ultimate maximum
is 1A. Do you know the stall current of your motor?

Have you double checked the pin-out?

Alright below are the tests I have run..

A. Powering via Arduino 5v and ground .. motor works
B. Powering from power supply 5v and ground to motor power on the motor
C. Powering from power supply 5v and ground to motor and integrating with circuit/arduino no bueno.
D. Tried C but also applied ground from digital pwm and still does not work.

pwm 3 and pwm 9 are used in the circuit, the resistor is hot to the touch when everything is powered on. motor does not power. Everything works until i use external power supply output of 5v 10amp.. attaching Schematics to this post code below

int motorPin = 9;
 
void setup() 
{ 
  pinMode(motorPin, OUTPUT);
  Serial.begin(9600);

} 
 
 
void loop() 
{ 

      analogWrite(motorPin, 100);
    
  
}

Firstly never power a motor from the Arduino 5V rail - you risk frying the entire
Arduino board.

Never power motors and logic chips from the same supply rail and things
should be reliable.

Your circuit is quite wrong (its also hard to follow because you don't arrange things
the conventional way with voltage rails at top and bottom).

This diagram shows how to use an NPN transistor to switch a motor:

Only use 220 ohms, not 1k on the base, and what is labelled 10V is your motor
supply rail (not Arduino 5V). Grounds are commoned at the transistor emitter.

That solution seems to not work.. at this point I have the following

Emitter = Ground from Arduino digital
Ground from 5v power supply
Ground from 6v motor

Base = 270ohm or 1k ohm Resistor to digital pin ~3

Collector = Diode with flow going away from transistor to positive lead of 6 volt motor

Using the same code above and having switched to motorPin = 3 still no go :-/

Motor connects ACROSS the diode.
+motor to + supply.
-motor to collector, NOT to ground.

Look at MarkT's diagram.
"load" box = motor.
Leo..

Hi,
Do you have a DMM so you can measure some voltages for us.
Have you got the transistor connected the correct way.
Is your transistor faulty due to the problems you have had.
If the resistor to the base is getting hot, I would say your transistor is faulty.

Can you post a picture of your project so we can see your connections please?

The circuit you have attached make no sense, for a start you have the transistor connected the wrong way round.

Tom..... :slight_smile:

I am a beginner but this sure is frustrating,

Based on more testing and changing to new transistors to avoid error from breaking previous transistors I now have the following with the above code:

C (left leg)
5v power supply ground
digital ground arduino

B (middle leg)
pin ~3 resistor 270ohm to arduino

E (right leg)
Motor ground -> diode connected at motor location going back to power supply 5v

Motor positive - going to power supply 5v

Still no go :-/

Hi
Have you got a meter to measure some voltages for us?
If your sketch is using output 9 as control, why is the resistor connected to pin output 3?

Tom.... :slight_smile:

Two breadboards. Very confusing.
I assume the transistor is on the transparent board, but I don't see the emitter/ground wire returning to the Arduino.
Leo..

I did connect the arduino ground via the green cable unless you are referring to the additional ground on the analog input side which i will try to add today. If this does not work... than I thoroughly hate Adafruit I thoroughly hate pn2222a transistors and I will go buy a multi-meter (definitely not a FLUKE because they look really hot but I can't afford it) and start pulling some readings to share so that we can determined where my retardation has occurred. Thanks everyone though for your insights.. enjoying the process of learning and smashing my head :slight_smile:

C (left leg)
5v power supply ground
digital ground arduino

B (middle leg)
pin ~3 resistor 270ohm to arduino

E (right leg)
Motor ground -> diode connected at motor location going back to power supply 5v

Still very wrong, why did you not go with MarkT's diagram?
It should be:-

C (left leg)
Motor ground -> diode connected at motor location going back to power supply 5v

B (middle leg)
pin ~3 resistor 270ohm to arduino

E (right leg)
5v power supply ground
digital ground arduino

Maybe try it old school just temp remove the arduino and put 5 volts to the input resister to the base of transister and gnd to common gnd. This will tell you if your circuit is wired correcly and working without the arduino.