DC motor is not working in real life circuit

Hi. I'm struggling to understand what's the real problem with my DC motor circuit. I've made a prototype on Thinkercad and everything is fine there. But whenever I physically build this, the motor is not spinning.
At first I thought that the mosfet was broken but I made some tests and it actually works. So I don't know what the real problem could be.

Here's the circuit:

and this is the code:

const byte button = 2;
const byte dc = 9;
const byte trimmer = A5;

void setup()
{
  Serial.begin(9600);
  pinMode(button, INPUT_PULLUP);
  pinMode(dc, OUTPUT);
}

void loop()
{
  float dcMotorSpeed = map(analogRead(A5), 0, 1023, 0, 255);
  
  if(!digitalRead(button))
    analogWrite(dc, dcMotorSpeed);
  else
    analogWrite(dc, 0);

  Serial.print("DC status: ");
  Serial.print(!digitalRead(button));
  Serial.print("\tDC motor speed: ");
  Serial.print(map(dcMotorSpeed, 0, 255, 0, 100));
  Serial.println("%");
}

There are several problems with the circuit. PP3 block batteries, if that is actually what you are using, are designed for low power circuits like smoke alarms, not motors.

Please have Fritzing produce a schematic, with all the parts and pins properly identified and labeled, rather than the above. The transistor needs to be identified, and it requires a gate or base resistor in series with the Arduino output pin.

I've never used Fritzing. Is it free? Also I currently don't have a block batteries, I'm using jumpers

You posted a Fritzing diagram, and if it does not represent your circuit, it is misleading as well as wrong.

Please post a hand drawn wiring diagram (pencil and paper works) that represents your actual circuit, with pins and parts clearly identified and labeled. Also, post links to the parts, like the motor power supply.

Posting instructions can be found in the "How to get the best out of this forum" post, linked at the head of every forum category.

In TinkerCad in the upper right hand corner there is an icon you can click to produce a schematic view of your circuit. Do that.

Connect the blue wire with ground...
The motor should run now...
If so: your button should be rotated by 90 degrees.

Hi, @untiziotizio
Welcome to the forum.

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Can you post some images of your project?
So we can see your component layout.

Do you have a DMM? Digital MultiMeter?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

The button is working fine, I don't get why should I connect the blue jumper to the ground

I know but it doesn't really help. It's always a bit messy but here is it:

Why you need the schematic if there's already a clear image of what the real circuite should look like. For the components, they're the ones provided in the Arduino starter kit

How did you test that?

Because it makes more sense, such as MOSFET connections, switch connections.
So much better, you just need to refine your layout, but this one is good.

What is your MOSFET part number?

If you pull out the wire from gate to UNO and connect the gate to +5V what happens?
If you then connect the gate to gnd what happens?

Can I suggest at least a 10K resistor from MOSFET gate to gnd.

Tom.. :smiley: :+1: :coffee: :australia:

If you mean the mosfet model by "part number" it's an IRF520. So I have (looking from left) Gate, Drain, Source. Also I don't quite understand the:
"If you pull out the wire from gate to UNO and connect the gate to +5V what happens?
If you then connect the gate to gnd what happens?"

Are you trying to tell me that I'm short-circuiting? I shall put the resistor before the gate or after the source?

Hi, @untiziotizio

Disconnect R1 at A from the controller, then connect A end of R1 to 5V.

Disconnect R1 at A from the controller, then connect A end of R1 to 9V.

Tom.. :smiley: :+1: :coffee: :coffee: :coffee: :australia:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.