I am trying to use limit switches to stop a rotating platform at certain spots, but I can’t figure out how to have the switches work.
- Define the Variable
A. Click on the variable box at the start of the program
B. Define the variable, name it limit and for type select integer - Drag in a limit switch module and make it so it’s defined as the limit that you set up as the variable
- Drag in the module IF, it will be under program flow
- Set it so that it looks something like limit == 0
A) This will make it so that if the limit switch is pressed in it will read the section of code - Drag in an else module, this will also be under program flow
A) Drag in whatever you want your robot to do when the limit switch is not pressed in - Make sure you put the entire thing in a while loop for 1==1.
If you want to set a rotating platform to stop at many different points, it might be much easier to use a optical shaft encoder or something like it. It’ll read the exact position and stop the axle from rotating.
I tried your instructions, but whenever I put a “==0” in it I can’t drive the robot with the remote.
Oh sorry, I didn’t realize you wanted to be driving your robot as well. Just put a tank module into the else and also into the if. Same module, just copy and paste.
This is such a simple program.
The answer is in the manual that vex gave you with the programming kit.
If you read it thoroughly you will be able to program this really fast and easy.
Or perhaps put it in one place above or below the If-Else statement(s).