Thanks a lot!
I have finished my code, and appreciate all the comments.
Now I have a working code with variable speed control. I needed to map the potmeter to prevent stalling the gearmotor. Now i can start over again, trying to make a state machine 
const int motor = 12; // motor channel A on pin 12
const int brake = 9; // brake channel A on pin 9
const int limitBEGIN = 4; // limit switch BEGIN on pin 4
const int limitEND = 5; // limit switch END on pin 5
const int killSwitch = 6; // killSwitch on pin 6
const int motorSpeed = A5;
int currentSensing = A0; // read current on motor
int limitBeginState = 0; // variable to hold status
int limitEndState = 0; // variable to hold status
int killSwitchState = 0; // variable to hold status
int motorSpeedValue = 0;
void setup() {
pinMode(motor, OUTPUT); // initiates motor channel A
pinMode(brake, OUTPUT); // initiates brake channel A
pinMode(limitBEGIN, INPUT); // limit switch BEGIN
pinMode(limitEND, INPUT); // limit switch END
pinMode(killSwitch, INPUT); // Brake switch channel A
pinMode(motorSpeed, INPUT);
Serial.begin(9600);
Serial.println("Camera slider with limit and kill switch, variable speed:\n");
}
void loop() {
// read the state of switch:
limitBeginState = digitalRead(limitBEGIN);
limitEndState = digitalRead(limitEND);
killSwitchState = digitalRead(killSwitch);
{
motorSpeedValue = analogRead(motorSpeed);
motorSpeedValue = map(motorSpeedValue, 0, 1023, 130, 255);
analogWrite(3, motorSpeed);
}
if (killSwitchState == HIGH) { // brake out of while loop and brake the motor
do {
digitalWrite(brake, HIGH);
killSwitchState = digitalRead(killSwitch); // check switches
} while (killSwitchState == HIGH);
digitalWrite(brake, LOW); // brake off
}
if (limitBeginState == LOW && limitEndState == LOW) { // limit switches LOW and LOW
do {
digitalWrite(motor, LOW); // turn motor on clockwise:
digitalWrite(brake, LOW); // brake off
analogWrite(3, motorSpeedValue); // full speed
limitBeginState = digitalRead(limitBEGIN); // check switches
limitEndState = digitalRead(limitEND); // check switches
killSwitchState = digitalRead(killSwitch); // check switches
{
motorSpeedValue = analogRead(motorSpeed); // check and map motor speed
motorSpeedValue = map(motorSpeedValue, 0, 1023, 130, 255);
analogWrite(3, motorSpeed);
}
} while (limitEndState == LOW && killSwitchState == LOW); // do this until limitEndState changes or killSwitch is triggered
limitBeginState = digitalRead(limitBEGIN); // check switches
limitEndState = digitalRead(limitEND); // check switches
killSwitchState = digitalRead(killSwitch); // check switches
{
motorSpeedValue = analogRead(motorSpeed); // check and map motor speed
motorSpeedValue = map(motorSpeedValue, 0, 1023, 130, 255);
analogWrite(3, motorSpeed);
}
}
if (limitBeginState == LOW && limitEndState == HIGH) { // limit switches LOW and HIGH
do {
digitalWrite(motor, LOW); // turn motor on clockwise:
digitalWrite(brake, LOW); // brake off
analogWrite(3, motorSpeedValue); // full speed
limitBeginState = digitalRead(limitBEGIN); // check switches
limitEndState = digitalRead(limitEND); // check switches
killSwitchState = digitalRead(killSwitch); // check switches
{
motorSpeedValue = analogRead(motorSpeed); // check and map motor speed
motorSpeedValue = map(motorSpeedValue, 0, 1023, 130, 255);
analogWrite(3, motorSpeed);
}
} while (limitBeginState == LOW && killSwitchState == LOW); // do this until limitBeginState changes or killSwitch is triggered
limitBeginState = digitalRead(limitBEGIN); // check switches
limitEndState = digitalRead(limitEND); // check switches
killSwitchState = digitalRead(killSwitch); // check switches
{
motorSpeedValue = analogRead(motorSpeed); // check and map motor speed
motorSpeedValue = map(motorSpeedValue, 0, 1023, 130, 255);
analogWrite(3, motorSpeed);
}
}
if (limitBeginState == HIGH && limitEndState == LOW) { // limit switches HIGH and LOW
do {
digitalWrite(motor, HIGH); // turn motor on counter clockwise
digitalWrite(brake, LOW); // brake off
analogWrite(3, motorSpeedValue); // full speed
limitBeginState = digitalRead(limitBEGIN); // check switches
limitEndState = digitalRead(limitEND); // check switches
killSwitchState = digitalRead(killSwitch); // check switches
{
motorSpeedValue = analogRead(motorSpeed); // check and map motor speed
motorSpeedValue = map(motorSpeedValue, 0, 1023, 130, 255);
analogWrite(3, motorSpeed);
}
} while (limitEndState == LOW && killSwitchState == LOW); // do this until limitEndState changes or killSwitch is triggered
limitBeginState = digitalRead(limitBEGIN); // check switches
limitEndState = digitalRead(limitEND); // check switches
killSwitchState = digitalRead(killSwitch); // check switches
{
motorSpeedValue = analogRead(motorSpeed); // check and map motor speed
motorSpeedValue = map(motorSpeedValue, 0, 1023, 130, 255);
analogWrite(3, motorSpeed);
}
}
}