Limit Switch Programming Problem !HELP!

I have a question about programming more than 1 limit switch. I have programmed one switch using Easy C and the switch works perfectly. I programmed this one switch to turn right if it gets hit on the left side. When I tried programming two limit switches (one on the right and left side) they didn’t work correctly. When I placed the robot on the ground, it didn’t turn smoothly when the left or right limit switch was hit. Instead of turning smoothly, the robot twitched as it turned. The motors turned in the right direction but turned on and off repeatedly.

     When I programmed it I put both limit switches and "if else" statements into one while loop block (which was 1 == 1.)  One limit switch was in digital port 6 and the other in digital port 7.  The "If" statements had a Tank 4 motor block in it and the "else" statment had the robot turn left or right.  I don't know if this a programming error or if something else is wrong.

Can you please help me. It would help if you could send me a link or picture of the correct programming code for a 4 wheel robot (controlled by a controller) that has 2 limit switches on the front of the robot. If the left switch gets hit then it turns right, if the right switch gets hit it turns left.

     Thank you in advance, I really appreciate your help!!!!!!!!!!!!!!!!!!!!!

You should specify an amount of time you want your robot to turn when the limit switch is depresed. This will smooth out the turn.

You should be using the SetMotor Block to turn on and off the motors for turning. The Tank and Arcade blocks are only for driving the robot with the

The best examples of how to correctly code your program can be found in the help file.

I’d like to thank you for your help. The limit switches work perfectly now. Thanks for the advice!!!