How to power Motor and Arduino with single power source

Hi,
I am trying to look for the simplest way to power a DC motor that requires 6V current and Arduino with a single power source.

When I try to run this motor using the circuit below, the motor runs at a slower speed because Arduino can only provide so much current (~40-50mA).

Whats the best way to connect this motor so that I can get enough to power the motor (200mA) but also power Arduino safely.

Would it be OK to connect the circuit like this?

Tinkercad simulation shows that it should work, but when I try it on breadboard, the potentiometer seems to not respond correctly. Only when I turn it all the way to right, the motor suddenly start spinning, a slight turn to the left and it stops.

Note: This circuit will need to be externally powered.


This looks okay but . . .

Show us a good image of the ‘actual wiring’.

What is the MOSFET part number.

The potentiometer supply should be connected to the Arduino +5v header pin, NOT THE 8.4 VOLTS !

Ah ok, That might be the problem.
Let me re-wire the potentiometer and test.

larryd:

This looks okay but . . .

Show us a good image of the ‘actual wiring’.

What is the MOSFET part number.

The potentiometer supply should be connected to the Arduino +5v header pin, NOT THE 8.4 VOLTS !

Show us a good image of the actual wiring.

Sure,
Here are the images:

Great !

What is written on the MOSFET ?

Measure the voltage from A0 to GND and turn the potentiometer knob.

Does it go from 0V to 5V ?


Also, show us your sketch, use code tags (click on the </> icon in the posting menu).

Yes the voltage between A0 and GND goes from 0 to 5 when I turn the knob.
BUT
Only when I power the Arduino from the barrel plug.
When I try it using external power supply, it does not work :frowning:

Mosfet is: P30N06LE

Here is the code:

int analogValue = 0;

int pot = A0;
int motor = 3;


void setup()
{
  pinMode(pot, INPUT);
  pinMode(motor, OUTPUT);
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(9600);
}

void loop()
{
  Serial.println(analogRead(pot));
  analogValue = analogRead(pot);
  analogWrite(motor, map(analogValue, 0, 1023, 0, 255));
  delay(10); // Delay a little bit to improve simulation performance

}

pinMode(pot, INPUT); Remove this line of code as it is not needed.


Only when I power the Arduino from the barrel plug.
When I try it using external power supply, it does not work

Well, you do not have anything going to the Vin header pin so how are you powering the UNO from an external power supply ?


Note do not use the barrel plug and the Vin pin at the same time.

Thanks for your reply.
Can you guide me how should I connect VIN to my power source?
Should the +ve go to VIN?

VCN6oG3_d.jpg

VCN6oG3_d.jpg

YEs great, Thats what I was going to do.
Plus you also suggested that my POT should connect to Arduino 5V as well.

So here is my updated circuit, let me know if this looks goo dnow:

Plus you also suggested that my POT should connect to Arduino 5V as well.
Yes, I used the wrong image.

So here is my updated circuit, let me know if this looks goo dnow:
Looks okay.

BTW it is best to add the jumpers across your power supply rails too.

Excellent, and good suggestion, I should add those jumpers across rails :slight_smile: I end up squeezing wires in one corner.

larryd:
pinMode(pot, INPUT); Remove this line of code as it is not needed.

A quick question about this comment.
If I do not specify potentiometer pin as output, will still be able to read it's value in my loop function?

I am writing that value to the PWM pin.

Pins default to INPUT, which is what you specified. If you don't specify an OUTPUT pin you get in trouble.

But I must admit I usually specify the mode for all the pins I'm using. It's makes it easier for people who don't remember what the default is to work out what's intended when they're reading the program.

Steve

Oh ok, thanks for explaining that :slight_smile:

Interestingly, I came across this today.

PWM Motor speed controller.

Would you say that this can perform the task of what I am trying to achieve with Arduino here?
The overall project cost could drastically reduce if so.

It's able to handle voltage up to 15V and current up to 2A.

I have not used it before, so curious to know.

Thanks

If all you want is to control the speed of a DC motor by turning a knob then yes that plus a battery should do it.

Steve

thanks Steve