Are you limit switches wired correctly? the switch needs to be wired from signal too ground. the signal pin is held high until you ground it. so the value that you read will be inverted. you either need to rewire the switch, or put a not in front of the limit switch, such as
Code:
If(!limitswitch.Get())
{
motor.Set(.5);
Wait(sometime);
motor.Set(0);
}