control dc motor position

If, as you say, the push button = "range" (why?) then your problem may be that your if statements are comparing the push button pin number and not a value read from the pin...at least that seems to be a very common error. Where is the rest of the code so we can check?

Steve