Motors Turn on When Micro Plugged In

I am building a quadcopter with four motors controlled by N-MOSFETS off of an Arduino Micro. The Micro uses PWM and controls each motor individually. However, when I plug the Micro into the slots I have available for it (headers on the control board with the pwm connected to the MOSFETs) the motors instantly turn on. I do not have the Micro connected to the computer, it is being powered by the battery for the drone. Why do the motors instantly turn on? Can this be solved by something as simple as a pull-down resistor?
When I do not power the micro off of the battery and instead off of the computer, it performs how it should (controlling the motors only when I tell it to.) Any help is appreciated, thanks!

Can you post a wiring diagram? A pic of a hand drawn diagram will do if you label the pins.

Here is an earlier fritz I made. Just substitute the Uno for a Micro.


Yes, there are more sensors than just an infrared.

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

[code] Paste sketch here. [/code]

Your gates on the MOS FETs should be wired similar to Q3 in this image.

.

It seems you have swapped gate and source of the (unknown) mosfets in your diagram (post#2).

Must use a (10k) resistor from each PWM in to ground, to stop the gate from 'floating' during bootup.
And a 150-220ohm pin protection resistor between PWM pin and gate.
See Q3 in the diagram of larryd.

But maybe it's just the code (which you didn't post).
Leo..

Hi,

However, when I plug the Micro into the slots I have available for it (headers on the control board with the pwm connected to the MOSFETs) the motors instantly turn on.

Do I understand you are plugging the Micro into a powered circuit, that is the battery is turn ON.
Switch the battery OFF, before plugging anything in! ! !

Tom... :o :o :o

Ok, I will try and add resistors similar to Q3.

Wawa:
It seems you have swapped gate and source of the (unknown) mosfets in your diagram (post#2).

Yes, I did accidentally switch the MOSFETS around in the diagram, it should be GDS, which I followed on my actual circuit.

TomGeorge:
Hi,Do I understand you are plugging the Micro into a powered circuit

Don't worry, I plug the battery in after the micro is plugged in, sorry if i didn't make that clear.

As for code, this is it, nothing complicated:

int motorPin1 = 12;
int motorPin2 = 11;
int motorPin3 = 9;
int motorPin4 = 10;
int speed;
 
void setup() 
{ 
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorPin3, OUTPUT);
  pinMode(motorPin4, OUTPUT);
  Serial.begin(9600);
  while (! Serial);
  Serial.println("Speed 0 to 255");
} 
 
 
void loop() 
{ 
  if (Serial.available())
  {
    int speed = Serial.parseInt();
    if (speed >= 0 && speed <= 255)
    {
      analogWrite(motorPin1, speed);
      analogWrite(motorPin2, speed);
      analogWrite(motorPin3, speed);
      analogWrite(motorPin4, speed);
      Serial.println(speed);
    }
  }
}

Try: before the pinMode lines do a digitalWrite similar as below.
example:
digitalWrtie(motorPin1,LOW);
pinMode(motorPin1, OUTPUT);
etc.

Also add the two resistors as mentioned.

.

Hi,

However, when I plug the Micro into the slots I have available for it (headers on the control board with the pwm connected to the MOSFETs) the motors instantly turn on.

"When I turn power ON, after plugging the Micro into its headers, the motors instantly turn ON."

Better.....

Tom.. :o :o :o

Well, I just plugged in the Micro one pin over, putting 7V to the ground pin and ground to the reset pin. Pretty sure I fried it so I won't be able to see if it works or not until I get a new one. Thanks for the help though!