Re: Why is this servo program not running
Like rcahoon said, the first problem is the lack, and in some cases abundance, of brackets. So here is it cleaned up:
But there is a small problem in the logic of the code, so lets go through the code:
So let's say that joystick button 1 is pressed, it will set the servos to 67, if it is released they will be set to 0. So far so good.
So let's say that joystick button 2 is pressed, it will set the servos to -67 (I am not 100% sure, but I think in RobotC the servos values are 0-255), if it is released they will be set to 0.
On their own they both look fine, but together.
If button 1 is pressed, the first if/else will set the servos to 67, then the second one (unless you have both button 1 and 2 pressed) will set them to 0 (if both are pressed it will be -67). It will loop, as long as you have a button pressed, setting them to 67, 0, 67, 0, and so on, the servos will do nothing or twitch back and forth a little. The same thing will happen if button 2 is pressed. So the two statements need to be contained in one statement so that the servos can never be set to more than one value in one loop of the program, such as:
Hope this helps.