Arduino 12VDC motor controller with limits

Ok,

Thanks for all the advice.

I made it a 2 button system and got myself a few leds, resistors and a breadboard.

Got a bit of code sort of working, but need some help.

The buttons work, but it does not keep the trigger until the limit is reached, as soon as I release the button, the led goes of.

I would like it to be pressed once, motor switches on and turns in direction of what button I pressed until the limit is reached then stops and cant go further, only in the other direction.

Here is the current code:

const int pwm = 9 ;
const int in_1 = 2 ;
const int in_2 = 3 ;
const int UpButton = 10 ;
const int DownButton = 11 ;
const int Upper = 12 ;
const int Lower = 13 ;

int UpButtonState = 0 ;
int DownButtonState = 0 ;
int UpperState = 0 ;
int LowerState = 0 ;

void setup() {

 pinMode(pwm, OUTPUT) ;
 pinMode(in_1, OUTPUT) ;
 pinMode(in_2, OUTPUT) ;
 pinMode(UpButton, INPUT_PULLUP) ;
 pinMode(DownButton, INPUT_PULLUP) ;
 pinMode(Upper, INPUT_PULLUP) ;
 pinMode(Lower, INPUT_PULLUP) ;

}

void loop() {

 UpButtonState = digitalRead(UpButton) ;
 UpperState = digitalRead(Upper) ;
 DownButtonState = digitalRead(DownButton) ;
 LowerState = digitalRead(Lower) ;

 if (UpButtonState == LOW && UpperState == HIGH)  {
   MoveUp();
 }
 else if (DownButtonState == LOW && LowerState == HIGH)  {
   MoveDown();
 }
 else {
   digitalWrite(in_1, LOW) ;
   digitalWrite(in_2, LOW) ;
   analogWrite(pwm, 0) ;
 }
}

void MoveUp() {

 digitalWrite(in_1, HIGH) ;
 digitalWrite(in_2, LOW) ;
 analogWrite(pwm, 255) ;
}


void MoveDown() {

 digitalWrite(in_1, LOW) ;
 digitalWrite(in_2, HIGH) ;
 analogWrite(pwm, 255) ;
}