2 motor limit switch

how do you program a limit switch to an arm that is powered by 2 motors and controled by one joystick?

One bowl of robot limit switch coming up!

What we need:
1 x Limit Switch Plugged Into Digital I/O Port 5-10
1 x Limit Switch Block
1 x RX Input block
4 x Motor Blocks
1 x While Loop
1 x IF Statement
1x ELSE Statement
Cup ’ O Variables

1st you need a while(1) loop to keep checking out sensor and joystick values
2nd you need to read the value from the joystick and save it to a variable
3rd you need to read the value from the limit switch and save that to a variable
4th you need to create a if statement something like
if (Limit == 0 && Joystick > 128) //( Limit = pressed && Joystick > Down)
then stop ( grab some motor blocks for this)
else
then write the variable from the joystick variable to the two motors Depending on which way they face one may have to be inverted with a little math.

Good Luck!
You can look up data on a specific block by clicking the help button with the dialog box open.

how do i invert the variable?

edit: nevermind i figured it out

Great success! :slight_smile: