Troubleshooting dc motor motion control

I have a project with the goal in mind being to reliably activate and drive a dc motor with PIR sensor. The code is working, but the physical circuit will not even power on. Anyone know where i am going wrong? Any suggestions are valued!

Here is the physical circuit

Please post proper schematics.
Please post autoformatted code using code tags.

"the physical circuit will not even power on"...
What do You include in "the circuit"?

What measurements have You done?
If USB is not powering up the controller things are really bad.

Im new to this, so i don't understand much of what you are asking. The usb powers up the controller, the circuit does not. I did not create this, it is a circuit i followed through a tutorial that is supposed to accomplish the end goal. (Atleast it did in tinkercad)

Okey. This doesn't look easy.
Explain what You don't understand.

Running motor current through a breadboard exceeds the capacity of the breadboard.

I apologize for my current lack of knowledge, im really just confused as to why this works on tinker cad, but not physically. Here is the tutorial i followed that got me to where i am. I assumed I would just be able to copy and upload the code, then make the connections with the same components

You need to tell us the identification of all the parts (post links) and identify individual component leads.

With Fritzing diagrams it is almost impossible to check whether you have a transistor wired correctly. We recommend to avoid posting them, and to post a schematic instead.

Hi, @dqtreats98
Welcome to the forum.

To add code please click this link;

We need to see your code?

Does your motor run if you connect it directly to the battery?

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

It's okey to be new, ignorant. We are all born without knowledge.
However, reading the replies, doing as much thinking as You can, and replying back makes helpers keep on. If You don't reply to replies, helpers jump off, gives You no help.

Im sorry for the delay, here are all of the components i have in this circuit

Uno r3

Breadboard

Wires

Elegoo EL-CP-004 120pcs... https://www.amazon.com/dp/B01EV70C78?ref=ppx_pop_mob_ap_share

I stole the mosfet from this board

Onyehn 0-24V Top Mosfet Button... https://www.amazon.com/dp/B07GLNCRR4?ref=ppx_pop_mob_ap_share

IN5817 diode

For whatever reason the forum is making me fight tooth and nail to provide you further links and wont allow me to email you media, if there is another way i can provide the links please let me know. I have further links for dc motor and pir sensor.
Hopefully this video link works, it is the tutorial i used for the project. My new most current issue is that the motor is now running weather it detects motion or not

It's an anti-spam measure applied to new users. I think the restriction should be lifted now, so you can try again.

If you would like to learn what is required to attain the next "trust level" with the forum software, which comes with additional privileges, you can read this:

1 Like

IRF520 is not a logic level (3.3 - 5V) MOSFET, although it MIGHT pass an Amp or 2 with 5V on its gate, IF it survived desoldering and handling without static preventive measures. Does the motor run when connected directly to 9V? Post your code.

1 Like

If you want to go rhe easy route.

Write take the blink sketch.
Make it bring the mosfer high every 10 seconds for two seconds.

Make one part work.
Pen and paper sketch of the mosfet connections.

Once you sorted that out.

Find a PIR tutorial.
Should be dozens that are simple.

Once you can get each to work by themselves then combining them should be easy.

Edit add
Do you have any more of those mosfet modules?

1 Like

if yo have any more of those MOSFET modules, use one
here is code for it.

https://robojax.com/learn/arduino/?vid=robojax-IRF520-MOSFET

it looks like you have the FET signal connected to the PIR ?
the white wire seems to cover itself... maybe pin 3 ?

what you should have is the PIR sending a signal to the UNO on a pin,
the, on a separate pin, a signal out to the MOSFET.

If you have not read the forum rules on how to post code with "code tags" please do so.
you use the </> button to create the box, and post your code in it.
as railroader said, please format your code. there is a menu button in the IDE that will organize your code with the proper indents and such.

also, you should verify your code to make sure there are no problems. if there are, you can copy and post those.

but the solution might be simple.

here are some simple tests.
plug the motor into the 9V rail, see if it works. then plug it back into the FET where you had it.

toggle the FET pin high/low with the sketch in the link (change to match your pin number)

bottom line is you have two circuits, motor driver and PIR.
get each to work separately and you are almost home.

your comment that the motor runs all the time could be in code, or could be in the circuit.
(kinda silly to say it might be in software or hardware....)

if you have more of those FET modules, use them as-is, don't remove the FET just to test.

1 Like

Fritzings are many times regarded as "not useful".
However.... The power source positive is connected to an upper rail on the breadboard but I would like a connection down to the lowest rail powering the controller.

1 Like

const int pirPin = 9;
  const int motorPin = 2;
  int switchstate  = 0;

void setup()
{
  pinMode(pirPin, INPUT);
  pinMode(motorPin, OUTPUT);
}

void loop()
{

 switchstate = digitalRead(pirPin);
  if (switchstate == HIGH) {

  // High means there is a motion detected by PIR sensor
  
    digitalWrite(motorPin, HIGH);
  
  }
  
  else{  

  // Low means no motion detected by PIR Sensor
  
    digitalWrite(motorPin, LOW);
  }

Here is my code. Im sorry for the delay, work has been hectic. I really appreciate your response and suggestions, the info you provided has been very helpful in learning about this.

Did you get the PIR to work?

I point it away from me into the empty part of the room
Then put my hand in front and trip it.
The PIR has an output for about 15 seconds? Then goes back to ready.

If you got the thing to work, what do you want to do next?