Arduino ground to mosfet doesn't work

So I built myself a circuit that controls a fan using a mosfet and arduino.
When I don’t have the arduino plugged in the circuit and I give the gate negative or positive it works, the fan turns off and on.

But when I plug the ground of the arduino in the source and plug the gate into pin 10 of the PWM pins on the arduino and I try to control it using code, it doesn’t work. Even after that when I remove the arduino from the circuit and I give the gate positive or negative it doesn’t work anymore! I have to remove the mosfet and plug it back in.

This is the mosfet I am using: http://www.onsemi.com/pub/Collateral/MTP3055VL-D.PDF
I have an image of the circuit in the attachments below and here is my code: hastebin

I hope someone can help me figure out what is wrong, thanks in advance.

Put a 1K resistor from gate to ground.

Nothing in your code is turning it off by the way.

welcome to the group.

Output to Gate to 10K to GND should work also.

BTW
Always show us your ‘current’ complete sketch.
Use CTRL T to format the sketch.
Please use code tags.
Use the </> icon in the posting menu.

[code] Paste sketch here. [/code]

Show us a good schematic of your circuit.
Show us a good image of your wiring.
Give links to components.
Posting images:

@bluejets...
Where did you see his code ?

lastchancename:
@bluejets...
Where did you see his code ?

If you read my post you can see I have link in there referring to my code but I might as well post it here:

//Variables
int fanPin = 10; //Fan is plugged into PWM 10

void setup() {
  // put your setup code here, to run once:
  pinMode(fanPin, OUTPUT);
  digitalWrite(fanPin, HIGH); //HIGH
}

void loop() {
  // put your main code here, to run repeatedly:
}

bluejets:
Put a 1K resistor from gate to ground.

Nothing in your code is turning it off by the way.

I'll try that soon, thanks a lot.
I know my code isn't turning it off, whenever I wanted to turn the fan off I just put LOW instead of HIGH and upload it and see if it works.

Thanks for pointing out the - and posting the code in </> tags…
It helps!
Cheers

larryd:
Output to Gate to 10K to GND should work also.

What do you mean with output? Should I just put a 10k resistor between the gate and ground?

bluejets:
Put a 1K resistor from gate to ground.

I don't have a 1k resistor. Am I able to use four 220 ohm resistors and one 120 ohm resistor in series? (Yes I know it is bunk but I need to know if it can work.)
And could you maybe edit the image of the circuit I posted since it's kind of confusing to me.

See the image below for typical output circuitry.

Outputs.jpg

The Q3 circuit is similar to yours, the relay in the drain would be exchanged for your fan.

Note the 10K and 220 resistor placement in the gate area.

Of course you need a logic level MOSFET when the Arduino controls it directly.

As mentioned, you are not controlling the fan in your loop() function.
Maybe put more thought into what you want to do.

void loop()
{
// put your main code here, to run repeatedly:
}

larryd:
See the image below for typical output circuitry.

Outputs.jpg

The Q3 circuit is similar to yours, the relay in the drain would be exchanged for your fan.

Note the 10K and 220 resistor placement in the gate area.

Of course you need a logic level MOSFET when the Arduino controls it directly.

As mentioned, you are not controlling the fan in your loop() function.
Maybe put more thought into what you want to do.

void loop()
{
// put your main code here, to run repeatedly:
}

I’m sorry but that diagram is a little to hard for me to understand, I just started arduino and that’s why I am asking if you could edit the image I posted in my initial post to show me where the resistors go.
I am using a logic level mosfet I also linked that in the initial post.
I’m not going to worry about code for now since I first need to make the system work, thats why I online input HIGH in the setup.

MosFetVent_bb.png

larryd:
MosFetVent_bb.png

Someone suggested I could use a 1k resistor instead of 10k is this true? If so where would I place that?

1K will make too heavy of a load on the gate, i.e. the 220 and 1K form a voltage divider and too much voltage will drop across the 220.

Use a 10K to GND so the full 5v developes across it.