View Single Post
  #11   Spotlight this post!  
Unread 05-02-2015, 06:32
curtis0gj curtis0gj is offline
Registered User
FRC #5033 (Beavertronics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Canada
Posts: 121
curtis0gj will become famous soon enough
Re: Limit Swtich Help

Quote:
Originally Posted by Jon Stratis View Post
The relays look good. In addition to double victor1's which have already been pointed out, consider the effect of pushing buttons 1 and 4 at the same time - you'll oscillate between full speed forward and full speed reverse. It's probably not a big deal, as your driver shouldn't be pushing them both at the same time anyways, but I personally like to prevent that sort of situation. Using some fairly simple logic, you can reduce everything dealing with the victors to a single if/else-if/else block. Something like:
Code:
if ()//the conditions you want it to go up
{
    //go up
}
else if ()//the conditions you want it to go down
{
    //go down
}
else
{
    //stop
}
You can set up the conditionals using the AND (&&) operator, the OR (||) operator, and the not (!). For example, to say "when button 4 is pressed and the limit switch is not pressed", you would do "xbox.getRawButton(4) || !limitPressed". Figuring out how to use logic like this is a very powerful tool while programming!
So when I go to add my second limit switch for the top could I use if(limit || limit2) or do I need a new if statement? Also I have been trying to figure out how to covert my victor buttons to axis would this be the correct way,
if(xbox.getRawAxis(I need to check mapping)) {
victor 1.set(1);
victor2.set(1);
}

Last edited by curtis0gj : 05-02-2015 at 06:46.
Reply With Quote