thanks a bunch for your help! I changed the lines you recommended and still wasn't getting the switchcase function to work properly. After reading up a little more on static variables, i realized the machine state change wasn't carrying through the end of the function. I made this change and it worked:
static enum {WaitingForSwitchOn, MotorMovingOut, DwellPeriod, WaitingForSwitchOff, MotorMovingIn} machineState = WaitingForSwitchOn;