Moving a motor with a switch. and mosfet

ok guys so i have an airsoft mosfet "GATE X-ASR" that controlls the a motor, im trying to use the arduino to turn the motor on for a specified time "lets say 500ms", then turns the motor off, the code im currently using is very messy as im trying diffrent things, the code below is the newest test code,

now i have it all wired up the right way and i can controll the mosfet with the arduino and a button connect to the arduino, the problem im having is that when the button is pressed it turns the motor on and off for example it will turn on for say 500ms then off for 1sec depending on what i tell it, but then while the button is still pressed it will loop, that's not what i want, i need to to turn on for say 1sec then off all the while the button is still pressed what i would have to do is release the button and press it again for it to spin for the 1 sec. what am i doing wrong?

im new to arduino code, but come from a Vb.net background. so im using diffrent code i find and i work out how it works that way, "i learn that way easier"

int DWELL = 500; // how long to open MOSFET ms
int RATE = 200; // how long to wait after closing MOSFET ms
int MOSFET = A0; // MOSFET control pin
int SEMI = A4; // semi auto switch pin
int FULLAUTO = A5; // full auto switch pin
int SEMISTATE = LOW; // start state of semi switch
int SEMISTATUS = LOW; // current state of semi switch
bool osf;

////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////

void setup() {
  // put your setup code here, to run once:
pinMode( MOSFET, OUTPUT ); // MOSFET
  pinMode( SEMI, INPUT_PULLUP ); // Semi Auto
  pinMode( FULLAUTO, INPUT_PULLUP ); // Full Auto
   digitalWrite( MOSFET, LOW );
}
////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////
void loop() 
{
//digitalWrite( MOSFET, HIGH ) ; // open MOSFET
//if (MOSFET,HIGH);
 //test;

/*
 
 */

digitalRead (osf);

if (osf == 1);
FULL();
if (osf == 0);
digitalWrite(MOSFET, LOW);

 
if (A5,HIGH);
//if(digitalRead(MOSFET) == HIGH)                  
//FULL();
digitalWrite (osf, 1);

digitalWrite(MOSFET, LOW);
 
  }






////////////////////////////////////////////////////////////////////
void FULL() 
 {

  //digitalWrite(LED_BUILTIN, HIGH);
                     digitalWrite( MOSFET, HIGH ) ; // open MOSFET
                                  callMillis(1000);//delay(1000);
                     digitalWrite( MOSFET, LOW ), callMillis(500); // close MOSFET
digitalWrite (osf, 0);
  
  }


void callMillis(unsigned long x)
{
  unsigned long presentMillis = millis();
  while(millis() - presentMillis != x)
  {
/////////////////////////////////////
  }
}

What is this doing?

bool osf; That is a byte with a value of ZERO until you set it true, then is is a value of 1.

And then you do this:

digitalRead (osf);

Which reads pin ZERO, unless osf is true then is reads pin 1.

Why?

Paul

i was trying to see if i was to read the osf 0 or 1 if that would turn the FULL(); on and off it was just a test

Volanaro:
i was trying to see if i was to read the osf 0 or 1 if that would turn the FULL(); on and off it was just a test

Then you want:

osf = digitalRead(pin_number);

Paul