Re: RobotC Guard Conditions
Hmm, you're on the right track, but there's a few things you need to know. First of all, putting loops in your driver-control program is typically not a good idea because all of the rest of your code will have to wait for the loop to finish before it runs. For example, you would be unable to drive around your robot while the claw was moving. I'm not 100% sure on this, but I believe you would be able to set the nMotorEncoderTarget when the button is pushed and the motor would automatically stop moving when it reached that target. In other words, you wouldn't need to worry about putting any code in to make it stop.
As far as making sure you don't jam your motor, you could put in a simple Boolean variable. Something like:
Then, in your code for opening and closing the claw:
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://cof7468.weebly.com/