Can't get my 6v motor to run.

So basically what I have is the arduino get's a signal from a switch(it will be a motion sensor). The switch gets 5V and goes to a digital input. Then I have a digital output that sends it's signal to a MOSFET. The MOSFET in turn takes power from 4 AA batteries and sends it to a 6V motor. I've tested all components and know they all work. I'm using this MOSFET setup here. (SparkFun MOSFET Power Control Kit - COM-10256 - SparkFun Electronics)Any ideas as to why this isn't working? Here is my code:

int PIR = 2;
int PUMP = 3;
//initialize Pin 2 as input and Pin 3 as output
void setup(){
  pinMode(PIR, INPUT);
  pinMode(PUMP, OUTPUT);  
  }
//Runs until shutting down. Wait for input, send output, wait one minute,etc
void loop(){
  { 
    if (digitalRead(PIR == LOW)){
      digitalWrite(PUMP, LOW);
      delay(200);
    }
    else
    {
      digitalWrite(PUMP, HIGH);
      delay(1000);
    }
  }
}

Here is my circuit(just replace the PIR sensor with a simple momentary push button switch for now):

Oh ya, if I try this code the motor will run constantly but in short bursts, not a constant power to it.

int PIR = 2;
int PUMP = 3;

//initialize Pin 2 as input and Pin 3 as output
void setup(){
  pinMode(PIR, INPUT);
  pinMode(PUMP, OUTPUT);  
  Serial.begin(9600);
}

//Runs until shutting down. Wait for input, send output, wait one minute,etc
void loop(){
  //read the output state:
  int outputState = digitalRead(PIR);
  //print the state of the output
  Serial.println(outputState);

      if (digitalRead(PIR == HIGH)){
      digitalWrite(PUMP, HIGH);
      delay(1000);
    }
  delay(2000);
}
  1. Your schematic shows the 9V battery as being shorted, rather than connected between the Arduino power input and ground. How do you actually have it connected?

  2. What part number mosfet are you using? Your schematic shows IRF9530, which is a P-channel mosfet and not suitable (the motor would run continuously), but the SparkFun board you linked to uses a logic level N-channel mosfet (which would be correct).

dc42:

  1. Your schematic shows the 9V battery as being shorted, rather than connected between the Arduino power input and ground. How do you actually have it connected?

That's just a basic 9V battery snap that plugs into the Arduino. I just didn't get too fancy with the schematic.

  1. What part number mosfet are you using? Your schematic shows IRF9530, which is a P-channel mosfet and not suitable (the motor would run continuously), but the SparkFun board you linked to uses a logic level N-channel mosfet (which would be correct).

Those are just the automatic labels that CIrcuitLab uses. I'm using the sparkfun one. This may be a wiring issue on the board itself. I'm still looking into it though.